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 – http://manikandanmv.wordpress.com/2008/09/23/ajax-asynchronous-javascript-and-xml/
Ajax GET request – http://manikandanmv.wordpress.com/2008/09/29/ajax-example/
Ajax POST request – http://manikandanmv.wordpress.com/2008/09/25/ajax-post-request/
IE browser failed to execute scripts in ajax response – http://manikandanmv.wordpress.com/2008/10/18/ie-browser-failed-to-execute-scripts-in-ajax-response/
Tags: AJAX, ajax basics, ajax example, ajax GET request, AJAX POST request, no-cache parameter, XHR