Stop jQuery .load response from being cached

前端 未结 14 2199
迷失自我
迷失自我 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:49

    Sasha is good idea, i use a mix.

    I create a function

    LoadWithoutCache: function (url, source) {
        $.ajax({
            url: url,
            cache: false,
            dataType: "html",
            success: function (data) {
                $("#" + source).html(data);
                return false;
            }
        });
    }
    

    And invoke for diferents parts of my page for example on init:

    Init: function (actionUrl1, actionUrl2, actionUrl3) {

    var ExampleJS= {

    Init: function (actionUrl1, actionUrl2, actionUrl3)           ExampleJS.LoadWithoutCache(actionUrl1, "div1");
    

    ExampleJS.LoadWithoutCache(actionUrl2, "div2"); ExampleJS.LoadWithoutCache(actionUrl3, "div3"); } },

提交回复
热议问题