Monday, 27 April 2015

Ajax data not getting updated in IE

Again an issue with Ajax and JSON in IE. I was working on an application that needs the updated data to be rendered once every minute. Everything works good in Firefox and Chrome. But again IE, only the first result set was getting rendered and the subsequent ajax calls data wasn't fetching the updated one. When explored on this issue, we found it was a caching problem. I did try adding a timer to the ajax call URL so that every call is unique but that did not work either. Then tried the attribute - {cache: "false"}and it started working :) There are scenarios where changing the url by just appending some additional unique parameter to the url everytime worked in IE but there could be an issue with cache and setting the cache attribute to false helps!! :)

JSON.stringify and JSON.parse not working in IE

While working with JSON data in  an ajax call, I was using the JSON.stringify and JSON.parse methods. Everything was working good in Chrome and Firefox but, as usual, it wasn't in IE. :( Then found this json2.js file that allows JSON.parse and JSON.stringify to work in any browser i.e. it has a global JSON object that has these two methods - stringify and prase implemented :) All, I had to do was just include this js file and that is it. It started working :)