Stop jQuery .load response from being cached

前端 未结 14 1887
迷失自我
迷失自我 2020-11-22 03:54

I have the following code making a GET request on a URL:

$(\'#searchButton\').click(function() {
    $(\'#inquiry\').load(\'/portal/?f=searchBilling&pid=         


        
14条回答
  •  孤独总比滥情好
    2020-11-22 04:36

    /**
     * Use this function as jQuery "load" to disable request caching in IE
     * Example: $('selector').loadWithoutCache('url', function(){ //success function callback... });
     **/
    $.fn.loadWithoutCache = function (){
     var elem = $(this);
     var func = arguments[1];
     $.ajax({
         url: arguments[0],
         cache: false,
         dataType: "html",
         success: function(data, textStatus, XMLHttpRequest) {
       elem.html(data);
       if(func != undefined){
        func(data, textStatus, XMLHttpRequest);
       }
         }
     });
     return elem;
    }
    

提交回复
热议问题