Learn AJAX

Asynchronous JavaScript And XML: A to Z blog…

Posts Tagged ‘object’

AJAX Basics

Posted by Lasantha Samarakoon on August 20, 2009

Today I’m going to talk to you about, AJAX Basics. As the previous post, you can see that in the AJAX model, data transfers happen via the AJAX Engine. So the very first thing we have to do is to understand and create this AJAX engine. AJAX engine is just an object which is called as XMLHttpRequest.  By creating an object of this XMLHttpRequest, you can communicate with the web server through JavaScript.

But when you try to create the object, Cross-Browser Compatibility will be an issue. Because you can’t create the object in non-Internet Explorer, in the same way as in Internet Explorer. That’s occurred because in IE, XMLHttpRequest come as an ActiveXObject, but in non-IE browsers it comes in native handler.

So here is how I going to create “XMLHttpRequest” object.

Creating XMLHttpRequest object

Creating XMLHttpRequest object

OK.. this is the way to create an XMLHttpRequest object. This code snippet will be working on Microsoft Internet Explorer as well as Non-IE browsers such as Mozilla Firefox, Opera, Safari or anything. By using this httpvariable, we can transmit data with the web server. I hope to show you an “Hello World” example in the next post.

Advertisements

Posted in Technology, Uncategorized | Tagged: , , , , | 2 Comments »