assuming have method wrapping jquery ajax method:
function getjson(url, completecallback, alwayscallback, failcallback) {    var newurl = location.protocol + "//" + location.host + url;  $.getjson(newurl).done(function (result) {     if (typeof completecallback == "function") {         completecallback(result);     }                 }).fail(function (jqxhr, textstatus, error) {     if (typeof failcallback == "function") {         failcallback(result);     } else {         alert("request failed " + url + " textstatus:" + textstatus + " error:" + error);     }         }).always(function () {     if (typeof alwayscallback == "function") {         alwayscallback();     }         }); } and call dosomething method, internally calls getjson. result getjson callback want pass first parameter of doresume; remaining arguments should passed methods signature.
function dosomething(a, b, c, id) { var url = '/mycontroller/getdata?id=' + id;     getjson(url, doresume(this.result, a, b, c)); }  function doresume(result, a, b, c) { } i tried achieve using keyword, result not assigned.
you need pass function not result of invocation
getjson(url, function(result){     doresume(result, a, b, c); }); 
Comments
Post a Comment