A collection of computer systems and programming tips that you may find useful.
Brought to you by Craic Computing LLC, a bioinformatics consulting company.
Friday, November 11, 2011
When jQuery $.ajax() keeps returning the same value on Internet Explorer
I just mentioned this in my last post, but it is important enough that I'm going to give it its own post!
If you have jQuery Ajax calls, such as $.ajax() , $.get(), etc., that are continually fetching data from a remote server, you may find this works on Firefox, Chrome, etc. but in Internet Explorer it keeps returning the same value.
IE has cached the first return value and thinks that you are making identical requests so it just uses the cached value and never contacts the server.
Turn off caching by adding a call to ajaxSetup at the start of your script block and set cache to false.
<script>
$.ajaxSetup ({
cache: false
});
[...]
</script>
The fix is simple once you realize it but it took me a while to figure it out this morning.
Debugging JavaScript is painful at the best of times. It's worse when you throw AJAX into the mix. So take small steps and test on multiple platforms right from the start. I need to learn that lesson.
Subscribe to:
Post Comments (Atom)
Contributors
Archive of Tips
-
▼
2011
(44)
-
▼
November
(11)
- strsplit in R
- Running R scripts on the Command Line
- Deleting a File that starts with '-' on UNIX
- Plotting a simple bar plot in R
- Captain Beefheart Song Titles
- When jQuery $.ajax() keeps returning the same valu...
- Updating a DIV with jQuery and Sinatra
- Latest version of jQuery on Google APIs
- Sorting on multiple String keys in Ruby
- Manipulating Model/Table/Controller Names in Rails
- Parsing 96 / 384 well Plate Maps
-
▼
November
(11)
No comments:
Post a Comment