Prevent browser caching of AJAX call result

后端 未结 21 1295
醉酒成梦
醉酒成梦 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:12

    JQuery's $.get() will cache the results. Instead of

    $.get("myurl", myCallback)
    

    you should use $.ajax, which will allow you to turn caching off:

    $.ajax({url: "myurl", success: myCallback, cache: false});
    

提交回复
热议问题