how to clear the cache data when using ajax?

前端 未结 6 2102
星月不相逢
星月不相逢 2021-01-25 17:44

I am using Ajax to retrieve the data from server as below based on some ID to perform auto suggest function. however when i submit the form and update the database, the auto sug

6条回答
  •  南方客
    南方客 (楼主)
    2021-01-25 17:57

    Easiest thing to do is use jQuery#ajax and disable caching.

    jQuery will suffix a parameter ?somenumber to your ajax call which just is sufficient to persuade the browser it cannot use cached data.

    I came across this once. Here's the answer I got: Why does jQuery.ajax() add a parameter to the url? .


    You could do the same thing manually too, but you would have to check if the addition of the parameter is all there is to it.

提交回复
热议问题