jquery - cannot callback data from $.post -


this question has answer here:

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

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -