jquery - cannot callback data from $.post -
this question has answer here:
- how return response asynchronous call? 24 answers
i'm cannot return data $.post function() pls help
refer url : data post request
test = { getdata : function (callback){ $.post("getdata.php",{data: data},function(data){ callback(data); } } } var data = test.getdata(callback); console.log(data);
** typeerror : callback not function
thank you
the callback
think not keyword or default argument. reference of function executed after ajax call performed. haven't declared what's callback
. have like:
function callback (data) { // data }
you can define callback
way:
var callback = function (data) { // data }
Comments
Post a Comment