5

I have the same problem as in here:

Why does JavaScript only work after opening developer tools in IE once?

except that mine is with chrome 44.

JavaScript code - mainly XHR and setInterval - works perfectly - when the developers tools are open

(could be only XHR issue)

This is a web app - i.e: a pop up widow, 300px in width, that is stationed next to whatever the user is currently working on.

the solution here: AJAX works if chrome dev tools open but not if chrome web tools closed?

does not seem to apply - since I'm using post for dynamic files

any ideas :-) ?

EDIT: as @michaelAdam enlighted - most of the problems are caching issues as I used quite a lot of XHR 'get' (which is not cached) hmm.. interesting to note: using:

$.ajaxSetup({ cache: false });

did not seem to do the trick. adding: @Mattisdada:

header("Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0");//Dont cache
header("Pragma: no-cache");//Dont cache
header("Expires: Thu, 19 Nov 1981 08:52:00 GMT");//Make sure it expired in the past (this can be overkill)

Prevent Chrome from caching AJAX requests

did seem to do the trick - so far...

Community
  • 1
  • 1
Nami Nam
  • 91
  • 2
  • 9
  • 2
    Could your old code be getting cached, and you have "Disable cache (while DevTools is open)" checked in your settings? – michaelAdam Aug 10 '15 at 11:14
  • 2
    You really should define what you been by "works" and explain exactly what doesn't work. What is it supposed to do? What is it currently doing? – musefan Aug 10 '15 at 11:20
  • seems `onload` issue. Any error if you have in the console and some code snippets where you feel it is not working? – Jai Aug 10 '15 at 11:27
  • Thank you @michaelAdam Disable cache was checked... any sugestions for my next move :-) ? – Nami Nam Aug 10 '15 at 12:20
  • Thank you @musefan - i believe its only the XHR – Nami Nam Aug 10 '15 at 12:20
  • Thank you @Jai - no errors. I do not believe its an onload issue - i played with this already :-) – Nami Nam Aug 10 '15 at 12:22
  • 1
    @NamiNam well with the way question is asked there is very little possibility to get answers, but if you could post your code then there might be we would be able to find out what is going on with the `xhr` calls. – Jai Aug 10 '15 at 12:25
  • Sounds like you might have a race condition somewhere. – Etheryte Aug 10 '15 at 17:17
  • 1
    @NamiNam The *(while DevTools is open)* part of michaelAdam's suggestion is important. It could be that there's a race condition that's only present when it IS caching. Maybe try turning that option OFF in developer tools, and see if you still reproduce it? – Katana314 Aug 10 '15 at 17:18
  • were you ever able to solve this? – Sunwoo Yang Jun 15 '17 at 16:29

1 Answers1

1

You need to make cache: false for jQuery AJAX, so that the response data won't be cached at browser. Another trick is too (if somebody is not using jQuery) make the URL unique by sending some unique value as parameter (like new Date().getTime()).

Example:

$.ajax({
    url: 'http://someurl', 
    cache: false, 
Kirk Beard
  • 9,569
  • 12
  • 43
  • 47
Suvi
  • 66
  • 5