javascript - why does returning the jquery AJAX promise in this function fail to give me the data? -


this ajax works on jsfiddle

var = $.ajax({     url: "/echo/json/",     type: "post",     data: {         json: json.stringify({             a: true         })     },     datatype: "json" });  a.done(function (data) {    console.log(data); }); 

why won't work when make a function , return ajax promise?

var = function () {     return $.ajax({         url: "/echo/json/",         type: "post",         data: {             json: json.stringify({                 a: true             })         },         datatype: "json"     }); }  a.done(function (data) {      console.log(data);  }); 

is not correct syntax? well, apparently not, how can build ajax request function? fiddle

since a function, have call it:

a().done(function(data) {     console.log(data); }); 

Comments

Popular posts from this blog

java - How to specify maven bin in eclipse maven plugin? -

single sign on - Logging into Plone site with credentials passed through HTTP -

php - Why does AJAX not process login form? -