Prevent browser caching of AJAX call result

后端 未结 21 1517
醉酒成梦
醉酒成梦 2020-11-22 04:47

It looks like if I load dynamic content using $.get(), the result is cached in browser.

Adding some random string in QueryString seems to solve this iss

21条回答
  •  醉梦人生
    2020-11-22 05:01

    Following the documentation: http://api.jquery.com/jquery.ajax/

    you can use the cache property with:

    $.ajax({
        method: "GET",
        url: "/Home/AddProduct?",
        data: { param1: value1, param2: value2},
        cache: false,
        success: function (result) {
            // TODO
        }
    });
    

提交回复
热议问题