I am breaking my head on an embedded project: Microchip ethernet/ wifi. I have a webpage where the data is loaded via ajax. Due to size limits, I am not using jquery, just Javascript AJAX.
PROBLEM: It seems to be all good in firefox. But in Chrome, It starts, and If I refresh, the AJAX stops working (sometimes, after repeated refreshes). No error is logged in the console.
I created a stripped down demo on
pastebin.com/test4/ajaxTest.html. It uses just the mchp.js
from the microchip demo. The page loads a number from another page via AJAX. This is repeated 100 ms, and If I cant get anything in 5 seconds ( ie ~50 attempts), it times out.
To recreate this error
, open the demo link in Chrome, and keep refreshing. I have a time out of 5 seconds. I am using latest version of Chrome
. Appreciate any hints. Thanks.
NOTE: Once it breaks, even if i keep refreshing, it wont work. but if I close the tab and open a new one, it works.
Thanks to @kol, figured it was a cache issue. So I have modified the url with a random number in the argument. Seems to be working now.
WireShark shows that after a while, your AJAX code gets HTTP/1.1 304 Not Modified
instead of HTTP/1.1 200 OK
. I think the answer gets cached by Chrome. You could append a random number argument to the URL to prevent caching (see here).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With