Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/mislz28/public_html/wp-content/themes/css-faq-v2/timeweather/timeweather.php on line 19
  • Uncategorized
16 February 2008

How the AJAX coded

Following are the steps that how you can code the Ajax Application:

Firstly, how to create an XMLHTTPRequest object. This process is different to some extent depending on your Internet Explorer that either it is (5+) with ActiveX enabled, or a standards-compliant browser for example Mozilla Firefox.

With IE, the request looks like:

http = new ActiveXObject(”Microsoft.XMLHTTP”); 

Whereas in a standards-compliant browser we can instantiate the object directly:

http = new XMLHttpRequest(); 

Secondly, you have to write an event handler. The event handler will use different methods of XMLHTTPRequest object to:

• make the request of the server

• check when the server says that it has completed the request, and

• deal with the information returned by the server

you can make your request of the server with the help of GET method to proper server-side script. See the example of event handler called updateData which suppose that you have defined your object of XMLHTTPRequest and now called it as http:

function updateData(param) {var myurl = [here I insert the URL to my server script];

http.open(”GET”, myurl + “?id=” + escape(param), true);

http.onreadystatechange = useHttpResponse;

http.send(null);
} Thirdly, you need a function of useHttpResponse that create when server is completed your request, and then perform an action with the data it has returned:
function useHttpResponse() {if (http.readyState == 4) {

var textout = http.responseText;

document.write.textout;

}

}

Tags:

This entry was posted on 16 February 2008 at 1:21 PM and is filed under Uncategorized. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

One comment

1. 
Dandy

Oh that’s really interesting info! I’m always trying to know the whole spector of things that I’m using)

12 March 2008 at 11:33 PM

Leave a reply

Name (*)
Mail (will not be published) (*)
URI
Comment