Template:Mainonly
"AJAX" is a popular buzzword. Standing for "Asynchronous Javascript And XML", it is often used to mean any form of interaction with the server between page loads, regardless of whether or not asynchrony or XML are actually involved. In technical forums, it is usually preferred to refer to it based upon the actual technology being used. Nowadays, this is generally the XMLHttpRequest object, often abbreviated to "XHR".
Note the license for code on this page. Here's a simple usage of an XMLHttpRequest object, to get the contents of a page on your server:
var xhr = new XMLHttpRequest();
xhr.open('GET', 'some.php', true);
xhr.onreadystatechange = function(){
alert(this.responseText);
};
xhr.send(null);
This code alerts the empty string, then the contents of the page, then the contents of the page again. To understand why, let's change it a bit:
var xhr = new XMLHttpRequest();
xhr.open('GET', 'some.php', true);
xhr.onreadystatechange = function(){
alert(this.readyState);
};
xhr.send(null);
License[]
This file is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This work is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
External links[]
- RFC 2616 "HTTP/1.1," §10 - Descriptions of all possible HTTP status codes.