jQuery Ajax


jQuery Ajax method is used to get data from server or post data to server.

jQuery ajax methid can be used in many ways. Some of these are as:-

  1. $.ajax( ajaxOptionParameter).done(function(serverData) { });
  2. $.ajax( { url:'http://www.edututorials.com/', success:function(serverData){ alert(serverData); });
  3. $.ajax( { url:'http://www.edututorials.com/', type:'GET' success:function(serverData){ alert(serverData); }, error:function(error){ alert(error); } });
  4. $.ajax( { url:'http://www.edututorials.com/', type:'POST', data:{ ID:3454, Name:'Edututorials' }, success:function(serverData){ alert(serverData); }, error:function(error){ alert(error); } }); .

It has several optional parameter and we can also get HTTP status code, XMLHttpRequest object. We can also specify the datatype to get like JSON, JSONP, XML, HTML, Text, File etc.