출처 : http://www.xul.fr/en-xml-ajax.html
The XMLHttpRequest class
Attributes
readyState | the code successively changes value from 0 to 4 that means for "ready". |
status | 200 is ok 404 if the page is not found. |
responseText | holds loaded data as a string of characters. |
responseXml | holds a Xml loaded file, DOM's method allows to extract data. |
onreadystatechange | onreadystatechange |
Methods
open(mode, url, boolean) | mode: type of request, GET or POST url: the location of the file, with a path. boolean: true (asynchronous) / false (synchrous). optionally, a login and a password may be added to arguments. |
send("string") | null for a GET command. |
create an instance
if (window.XMLHttpRequest) // Object of the current windows
{
request = new XMLHttpRequest(); // Firefox, Safari, ...
}
else
if (window.ActiveXObject) // ActiveX version
{
request = new ActiveXObject("Microsoft.XMLHTTP"); // Internet Explorer
}
wait for the response
request.onreadystatechange = function() { // instructions to process the response };
if (request.readyState == 4)
{
// received, OK
} else
{
// wait...
}
make the request itself
http_request.open('GET', 'http://www.xul.fr/somefile.xml', true);
http_request.send(null);
Comment on this post!