how to clear the cache data when using ajax?

前端 未结 6 2103
星月不相逢
星月不相逢 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条回答
  •  -上瘾入骨i
    2021-01-25 17:57

    I know that an answer has been accepted, but it didn't worked in my case. I already had no-cache header added. In my case this was the solution that really worked, because if you add a code after the request, it might not get executed in time for the second piece of code to run successfully:

    x = new XMLHttpRequest();
    x.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
            //execute the other code or function only when the page is really loaded!
        }
    };
    x.open("GET", "add your url here", true);
    x.send();
    

提交回复
热议问题