{"id":114,"date":"2013-10-25T09:31:04","date_gmt":"2013-10-25T07:31:04","guid":{"rendered":"http:\/\/46.105.150.90\/tstnunix\/?p=114"},"modified":"2013-10-25T09:31:04","modified_gmt":"2013-10-25T07:31:04","slug":"jquery-ajax-example","status":"publish","type":"post","link":"https:\/\/nunix.fr\/?p=114","title":{"rendered":"JQuery ajax example"},"content":{"rendered":"<p>A small post to present the complete JQuery.ajax syntax (<a href=\"http:\/\/api.jquery.com\/jQuery.ajax\/\" title=\"http:\/\/api.jquery.com\/jQuery.ajax\/\">http:\/\/api.jquery.com\/jQuery.ajax\/<\/a>). I&rsquo;ve also added a simple timer.<\/p>\n<p>You can start from this example to observe the diferent status \ud83d\ude09<\/p>\n<p>{codecitation class=\u00a0\u00bbbrush: javascript;\u00a0\u00bb}<\/p>\n<p>function log(msg) {<br \/> if (window.console) \/\/ IE8+ compliant \ud83d\ude09<br \/> console.log(msg);<br \/>}<\/p>\n<p>function callServer(url, data, callbackSuccess, callbackError) {<br \/> log(\u00ab\u00a0begin\u00a0\u00bb + url);<br \/> try {<br \/> var t = new Date().getTime();<br \/> var object = $.ajax(url, {<br \/> complete : function(query, status) {<br \/> log(\u00ab\u00a0complete\u00a0\u00bb);<br \/> },<br \/> \/\/ contentType :\u00a0\u00bbapplication\/json\u00a0\u00bb,<br \/> \/\/ dataType:\u00a0\u00bbjsonp\u00a0\u00bb,<br \/> \/\/ jsonp:&rsquo;onJSONPLoad&rsquo;,<br \/> data : {<br \/> \u00ab\u00a0data\u00a0\u00bb : data<br \/> },<br \/> error : function(d, s, q) {<br \/> callbackError(d, s, q, t);<br \/> },<br \/> success : function(d, s, q) {<br \/> callbackSuccess(d, s, q, t);<br \/> },<br \/> error : function(query, status, error) {<br \/> log(\u00ab\u00a0error\u00a0\u00bb + status);<br \/> },<br \/> success : function(data, status, query) {<br \/> log(\u00ab\u00a0success\u00a0\u00bb + status);<br \/> },<br \/> type : &lsquo;POST&rsquo;,<br \/> });<\/p>\n<p> object.done(function(data, textStatus, jqXHR) {<br \/> log(\u00ab\u00a0done\u00a0\u00bb + textStatus);<br \/> });<br \/> object.fail(function(query, textStatus, error) {<br \/> log(\u00ab\u00a0fail\u00a0\u00bb + textStatus);<br \/> });<br \/> object.always(function(query, textStatus, error) {<br \/> log(\u00ab\u00a0always\u00a0\u00bb + textStatus);<br \/> });<\/p>\n<p> log(\u00ab\u00a0ajax fired\u00a0\u00bb);<br \/> } catch (e) {<br \/> log(\u00ab\u00a0exception\u00a0\u00bb + e);<br \/> }<br \/> log(\u00ab\u00a0end\u00a0\u00bb + url);<br \/>}<\/p>\n<p>{\/codecitation}<\/p>\n<div>{jcomments on}<\/div>\n<p>\u00a0<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A small post to present the complete JQuery.ajax syntax (http:\/\/api.jquery.com\/jQuery.ajax\/). I&rsquo;ve also added a simple timer. You can start from this example to observe the diferent status \ud83d\ude09 {codecitation class=\u00a0\u00bbbrush: javascript;\u00a0\u00bb} function log(msg) { if (window.console) \/\/ IE8+ compliant \ud83d\ude09 console.log(msg);} function callServer(url, data, callbackSuccess, callbackError) { log(\u00ab\u00a0begin\u00a0\u00bb + url); try { var t = &hellip; <a href=\"https:\/\/nunix.fr\/?p=114\" class=\"more-link\">Continuer la lecture<span class=\"screen-reader-text\"> de &laquo;&nbsp;JQuery ajax example&nbsp;&raquo;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[25],"tags":[],"class_list":["post-114","post","type-post","status-publish","format-standard","hentry","category-js"],"_links":{"self":[{"href":"https:\/\/nunix.fr\/index.php?rest_route=\/wp\/v2\/posts\/114","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nunix.fr\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nunix.fr\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nunix.fr\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nunix.fr\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=114"}],"version-history":[{"count":0,"href":"https:\/\/nunix.fr\/index.php?rest_route=\/wp\/v2\/posts\/114\/revisions"}],"wp:attachment":[{"href":"https:\/\/nunix.fr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=114"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nunix.fr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=114"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nunix.fr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=114"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}