javascript - Wrapper for JQuery's ajax function. Callback fired, but no params -
I'm very new to JavaScript, so the question can be dummy. I receive a lot of posts and post requests in my code, so I decided to write the javascript function to call java's AJAX function
I call it like this:
url = "/ api / info"; Success on the Festival (data, textstats, jqXHR) {$ ("# results") Html ("hostname is" + datahostname); } Function onfell (jqXHR, textstats, error thrown) {$ ("# results"). Html ("Shutdown"); } // fire request getRequest (url, onSuccess (), onFail ());
The callback has been removed, but the data is undefined. In the end, I have decided to type the function again by writing:
function getRequest (url, success callback, failed callback) {$. Axx ({url: url, timeout: 3000), datatype: "Jason", success: function (data, textstats, jquxhr) {successful callback (data, textstatus, jxxhr);}, error: function (jkxhr, textstats, errorprobion) {Fail callback (jkxhr, textstatus, error trace);}}); }and its use is:
getRequest (url, onSuccess, onFail); As told by @ Fabricator
Comments
Post a Comment