Home » » jQuery Ajax

jQuery Ajax

Written By 1 on Monday, May 27, 2013 | 3:44 AM

jQuery Load Method
load(): Load a piece of html into a container DOM.
$('#result').load('ajax/test.html');

jQuery GET Method
$.get(): Use this if you want to make a GET call and play extensively with the response.
$.get('ajax/test.html', function(data) {
$('.result').html(data);
alert('Load was performed.');
});

jQuery POST Method
$.post(): Use this if you want to make a POST call and don’t want to load the response to some container DOM.
$.post('ajax/test.html', function(data) {
$('.result').html(data);
});

jQuery AJAX Method
$.ajax(): Use this if you need to do something when XHR fails, or you need to specify ajax options (e.g. cache: true) on the fly.
$.ajax({
type: "POST",
url: "some.php",
data: { name: "John", location: "Boston" }
}).done(function( msg ) {
alert( "Data Saved: " + msg );
});

0 Comment:

Post a Comment