javascript - Overriding jquery .load() function - handle callback -


i have overloaded .load() funciton of jquery meet crossdomain requirements.

(function ($) {      var _load = $.fn.load;      $.fn.load = function(url, params, callback) {          if (url.match('^http')) {              $(this).load("read_page.php?p="+url);             return this;         }         else{             return _load.apply(this, arguments);          }     } })(jquery); 

the "read_page.php" calls php curl page crossdomain.

the part of code calling above overrided function is:

$(trg).load(user_folder+shw+qs, function(){                         showerr("updation successfull", trg);                         $(".diverr").css("border-color","#4f8a10");                         $(".diverr").css("background","url(images/img_suc.png) no-repeat 10px 50%, left;");                         $(".diverr").css("background-color","#dff2bf");                     }).html(vloading); 

the .html(vloading) part doing fine code returns value of this.

the function(){...} part not working code has no part handle callback

need handle callback in custom override function.

try version:

(function ($) {      var _load = $.fn.load;      $.fn.load = function(url, params, callback) {          if ( url.match('^http') ) {             var params = params || {},                 callback = callback || function () {};             _load.call(this, "read_page.php?p="+url, params, callback );             return this;         }         else {             return _load.apply(this, arguments);         }     } })(jquery); 

Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c# - Copy ObservableCollection to another ObservableCollection -

All overlapping substrings matching a java regex -