10

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

1
  • 4
    The first sentence of the Wikipedia article could have told you that. Virtual -1 Commented Jan 12, 2011 at 22:05

4 Answers 4

10

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).

Sign up to request clarification or add additional context in comments.

3 Comments

thats what I meant, is it a separate language, or its a strategy(like DOM) and languages like Javascript can implement the strategy. thanks.
DOM isn't a strategy, it is an API.
CORRECTION, there IS a DOM api for javacript, but DOM alone is a strategy specified by w3c
2

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();
}

2 Comments

Globals?! Is this 1997? Oh, W3Schools, it is 1997.
ahaha, thats why i said old school ajax :P i still remember using that for the first time in high school early 00's :S
1

Actually, "AJAX" is short for Asynchronous JavaScript and XML. It is merely an asynchronous method of downloading data using Javascript.

1 Comment

thats what I meant, is it a separate language, or its a strategy(like DOM) and languages like Javascript can implement the strategy. thanks.
1

Neither. It refers to the task of making (using JavaScript) an HTTP request (and handling the response to it) without the user leaving the current page (e.g. by following a link or submitting a form).

There are several ways to do this (XMLHttpRequest, generating <script> elements, using a hidden iframe, etc) and many libraries (YUI, Mootools, Prototype, jQuery, Glow, etc) that implement helper methods to make it easier.

So it isn't a language, an API, a library or a framework. It is just a thing that can be done (in various different ways).

(It has also been used as a term to replace "DHTML", but its usage for such as since been replaced by "HTML 5" — marketeers need a new buzzword to describe "Doing any kind of fancy stuff on the web" every few years)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.