$.ajax ( { type: 'POST', url: '', dataType: 'json', data: {step:''} } ).done( function(infj) { $.each(infj, function(i,valu) { var zDiv=$('
',{'class':'img_div'}); var zImg=$('',{'src':valu['small'],'rel':valu['big']}); //-------------------------------- zDiv.append(zImg); $('#allpics').find('#zclose').before(zDiv); }); //---------------------------------------------------------------------------------------------- $.ajax ( { type: 'POST', url: '', data: {step:'', favpic:inpic} }).done( function(html) { //alert(html); }); //---------------------------------------------------------------------------------------------- $.ajax({ url: "test.html", context: document.body }).done(function() { $(this).addClass("done"); }); //-------------------------------------------- $.ajax({ statusCode: { 404: function() { alert("page not found"); } } }); //-------------------------------------------- $.ajax({ url: a_cross_domain_url, xhrFields: { withCredentials: true } }); //-------------------------------------------- $.ajax({ url: "http://fiddle.jshell.net/favicon.png", beforeSend: function ( xhr ) { xhr.overrideMimeType("text/plain; charset=x-user-defined"); } }).done(function ( data ) { if( console && console.log ) { console.log("Sample of data:", data.slice(0, 100)); } }); //-------------------------------------------- var jqxhr = $.ajax( "example.php" ) .done(function() { alert("success"); }) .fail(function() { alert("error"); }) .always(function() { alert("complete"); }); // perform other work here ... // Set another completion function for the request above jqxhr.always(function() { alert("second complete"); }); //-------------------------------------------- $.ajax({ url: 'ajax/test.html', success: function(data) { $('.result').html(data); alert('Load was performed.'); } }); //-------------------------------------------- var _super = jQuery.ajaxSettings.xhr; jQuery.ajaxSettings.xhr = function () { var xhr = _super(), getAllResponseHeaders = xhr.getAllResponseHeaders; xhr.getAllResponseHeaders = function () { if ( getAllResponseHeaders() ) { return getAllResponseHeaders(); } var allHeaders = ""; $( ["Cache-Control", "Content-Language", "Content-Type", "Expires", "Last-Modified", "Pragma"] ).each(function (i, header_name) { if ( xhr.getResponseHeader( header_name ) ) { allHeaders += header_name + ": " + xhr.getResponseHeader( header_name ) + "\n"; } return allHeaders; }); }; return xhr; }; //-------------------------------------------- $.ajax({ type: "POST", url: "some.php", data: { name: "John", location: "Boston" } }).done(function( msg ) { alert( "Data Saved: " + msg ); }); //-------------------------------------------- $.ajax({ url: "test.html", cache: false }).done(function( html ) { $("#results").append(html); }); //-------------------------------------------- var xmlDocument = [create xml document]; var xmlRequest = $.ajax({ url: "page.php", processData: false, data: xmlDocument }); xmlRequest.done(handleResponse); //-------------------------------------------- var menuId = $("ul.nav").first().attr("id"); var request = $.ajax({ url: "script.php", type: "POST", data: {id : menuId}, dataType: "html" }); request.done(function(msg) { $("#log").html( msg ); }); request.fail(function(jqXHR, textStatus) { alert( "Request failed: " + textStatus ); }); //-------------------------------------------- $.ajax({ type: "GET", url: "test.js", dataType: "script" }); //-------------------------------------------- $.ajaxSetup({ url: 'ping.php' }); $.ajax({ // url not set here; uses ping.php data: {'name': 'Dan'} }); //-------------------------------------------- $.ajaxSetup({ url: "/xmlhttp/", global: false, type: "POST" }); $.ajax({ data: myData }); //-------------------------------------------- $.ajax({ type: 'POST', url: url, data: data, success: success, dataType: dataType }); //-------------------------------------------- $.post('ajax/test.html', function(data) { $('.result').html(data); }); //-------------------------------------------- // Assign handlers immediately after making the request, // and remember the jqxhr object for this request var jqxhr = $.post("example.php", function() { alert("success"); }) .success(function() { alert("second success"); }) .error(function() { alert("error"); }) .complete(function() { alert("complete"); }); // perform other work here ... // Set another completion function for the request above jqxhr.complete(function(){ alert("second complete"); }); //-------------------------------------------- $.post("test.php"); $.post("test.php", { name: "John", time: "2pm" } ); $.post("test.php", { 'choices[]': ["Jon", "Susan"] }); $.post("test.php", $("#testform").serialize()); $.post("test.php", function(data) { alert("Data Loaded: " + data); }); $.post("test.php", { name: "John", time: "2pm" }, function(data) { alert("Data Loaded: " + data); }); $.post("test.php", { name: "John", time: "2pm" }, function(data) { process(data); }, "xml" ); $.post("test.php", { "func": "getNameAndTime" }, function(data){ console.log(data.name); // John console.log(data.time); // 2pm }, "json"); //--------------------------------------------
//-------------------------------------------- $.ajax({ url: url, data: data, success: success, dataType: dataType }); //-------------------------------------------- $.get('ajax/test.html', function(data) { $('.result').html(data); alert('Load was performed.'); }); //-------------------------------------------- // Assign handlers immediately after making the request, // and remember the jqxhr object for this request var jqxhr = $.get("example.php", function() { alert("success"); }) .success(function() { alert("second success"); }) .error(function() { alert("error"); }) .complete(function() { alert("complete"); }); // perform other work here ... // Set another completion function for the request above jqxhr.complete(function(){ alert("second complete"); }); //-------------------------------------------- $.get("test.php"); $.get("test.php", { name: "John", time: "2pm" } ); $.get("test.php", { 'choices[]': ["Jon", "Susan"]} ); $.get("test.php", function(data){ alert("Data Loaded: " + data); }); $.get("test.cgi", { name: "John", time: "2pm" }, function(data){ alert("Data Loaded: " + data); }); $.get("test.php", function(data){ $('body').append( "Name: " + data.name ) // John .append( "Time: " + data.time ); // 2pm }, "json"); //-------------------------------------------- $('#result').load('ajax/test.html'); $('#result').load('ajax/test.html', function() { alert('Load was performed.'); }); $('#result').load('ajax/test.html #container'); $('#a').load('article.html'); $('#b').load('article.html #target'); //-------------------------------------------- Footer navigation:
    //-------------------------------------------- Successful Response (should be blank):
    Error Response:
    //-------------------------------------------- $("#feeds").load("feeds.html"); $("#objectID").load("test.php", { 'choices[]': ["Jon", "Susan"] } ); $("#feeds").load("feeds.php", {limit: 25}, function(){ alert("The last 25 entries in the feed have been loaded"); }); //-------------------------------------------- $.ajax({ url: url, dataType: 'json', data: data, success: callback }); //-------------------------------------------- $.getJSON('ajax/test.json', function(data) { var items = []; $.each(data, function(key, val) { items.push('
  1. ' + val + '
  2. '); }); $('