javascript - Want to pass in returned data to my custom callback within jQuery's $.post() -


basically i'm creating own callback , passing method called _ajaxcall().

_ajaxcall() takes following parameters:

data = object containing user submitted data posted server posturl = url post callback = function expression called upon successful return of data server.

here _ajaxcall() method:

_ajaxcall: function (data, posturl, callback) {   $.post(posturl, {     data : data   }, 'json').done(function (returned) {     switch(returned.success) {       case true:         typeof callback === 'function' && callback(returned);         break;     }   }).fail(function (xhr, textstatus, errorthrown) {     if (status !== 200) {       window.location = document.url;     }   }); }  commentupdate : function(self) {   var posturl = '/submission/comment/' + self.attributes.commentid;    var data = {     action: self.attributes.action,     commentid : self.attributes.commentid,     comment: self.attributes.comment   };    var callback = function(returned) {     if (returned.success === true) {       // in here     } else {       // other crap here     }   };    this._ajaxcall(data, posturl, callback); } 

but it's not passing returned custom callback() method. why?


Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -