I’ve found other threads discussing .load and .ajax with Chrome and IE, but none with my particular problem.
I’m using the following code to call in a response from a servlet. The response should be 3 lines of text/html, but I can adjust to text/plain.
function checkProgress(){
$.ajax({
type: "GET",
url: "/myServlet",
success: function(result) {
$('#data').text(result);
setTimeout(checkProgress, 2000);
}
});
}
The idea here is to pull in the value ever 2 sec. and display in a div.
<div id="status" style="display:none;">
<h3>Status</h3>
<p id="data"></p>
</div>
The problem that I am having is that this will only load 1 time in Chrome and IE8. FF will repeat the load and I can see the value changing in browser.
Other issues I have seen talk about this not working at all in Chrome and IE8, but mine does work. It just will not repeat the load.
I have also tried this with .load because I want to maintain any html formatting and have encountered the same problem. I’m willing to skip the formatting for now so I can get this to update.
Any help is much appreciated!
EDITED
Researching Chrome a little more, I’ve found that it stops the ajax script when I submit the form. My page kicks off a rather lengthy servlet. I’m using the Ajax call to return status updates from the servlet. When I submit to start the servlet, the script that is running to report the status stops in Chrome. No errors. It just stops running.
This looks like a threading issue in Chrome. Is there a better way of doing this? Can I kick-off both the ajax and servlet at the same time with an onsubmit event?
IE caches ajax requests. How about adding a random string along with the url to make it a new request every time ?
Set the cache property value to false. So jquery will add a unique timestamp to all requests so it wont be a cached response everytime.