IE browser issue while sending ajax requests.


IE browser does not send ajax request if the url is same, simply get the results from cache. To avoid this and make a new request, we should append a no-cache parameter to each ajax request url.

getNoCacheValue(url) – method for dynamically getting current time in milliseconds and append that value to no-cache parameter.

function getNoCacheValue(url)
{
var d = new Date();
var appendstring = (url.indexOf(“?”) != -1) ? “&” : “?”;
var nocachevalue = appendstring + “no-cache=” + d.getTime();
return nocachevalue
}

sendAjaxRequest(url, divid) – method to send a ajax request and write the response text to given divid. In this method, getNoCacheValue(url) method called to avoid the cache problem in IE browser.

function sendAjaxRequest(url, divid)
{
url = url + getNoCacheValue(url);
var req = getXMLHttpRequest();
req.onreadystatechange = function(){ processResponse(req, divid) };
req.open(‘GET’, url, true);
req.send(null);
}

Ajax Basics – https://manikandanmv.wordpress.com/2008/09/23/ajax-asynchronous-javascript-and-xml/
Ajax GET request – https://manikandanmv.wordpress.com/2008/09/29/ajax-example/
Ajax POST request – https://manikandanmv.wordpress.com/2008/09/25/ajax-post-request/

IE browser failed to execute scripts in ajax response – https://manikandanmv.wordpress.com/2008/10/18/ie-browser-failed-to-execute-scripts-in-ajax-response/

Advertisements

Tags: , , , , , ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: