Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jquery ajax request cached

Tags:

jquery

when i request something via ajax if the input is the search the content seems to be cached? do i add a random number at the end of my query?

/search?input=test

to

/search?input=test&random=283928392

i think this would solve my problem. right? how do i write this in javascript

like image 947
newmem Avatar asked May 31 '26 21:05

newmem


1 Answers

At the beginning of your script (before any AJAX) put:

$.ajaxSetup({
  cache: false
});

That will solve your problem because it will automatically add the random number for every jQuery request. If you don't use jQuery for your AJAX this won't work.

like image 90
Alec Gorge Avatar answered Jun 02 '26 10:06

Alec Gorge