Wikia

JavaScript Wiki

Watchlist Recent changes

AJAX

"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);

LicenseEdit

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 linksEdit

Pages on JavaScript Wiki

Add a Page
75pages on
this wiki
Advertisement | Your ad here

Latest Photos

Add a Photo
17photos on this wiki
See more >

Recent Wiki Activity

See more >

Around Wikia's network

Random Wiki