Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is AJAX a separate language from Javascript, or is it a JavaScript framework?

Basically, is AJAX similar to JavaScript in syntax and semantics?

like image 526
dave Avatar asked Jan 12 '11 21:01

dave


2 Answers

AJAX isn't a language. It's a methodology, using JavaScript and XML (and I guess JSON fits in there as well), for a web client to asynchronously communicate with a server resource without requiring user-enacted browser events (such as page navigation).

like image 50
David Avatar answered Sep 23 '22 13:09

David


AJAX stands for Asynchronus Javascript and XML: http://en.wikipedia.org/wiki/Ajax_%28programming%29

Ajax is a javascript methodology to get data from a server in real time. It's syntax (particularly when used in things like jQuery) is just javascript... Today you can simply use one function to make an ajax call (using jQuery):

$.ajax({ url: "test.html",  success: function(){/*do stuff here*/}});

Old school ajax (as mentioned below, late 90's early 00's) looks more like this: http://www.w3schools.com/ajax/tryit.asp?filename=tryajax_first

function loadXMLDoc()
{
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","ajax_info.txt",true);
xmlhttp.send();
}
like image 35
Damien-Wright Avatar answered Sep 22 '22 13:09

Damien-Wright