I'm having a peculiar error with IE11 and ajax. For nearly all the requests I make using the code below, everything is fine, yet when I try use in conjunction with a copy+paste method, it returns an Access is denied error. So to summarise
Here is the AJAX code:
function ajaxRequest(requestName,responseFunction,parameters) {
var xmlhttp;
if (requestName.length==0) return;
if (window.XMLHttpRequest) {
xmlhttp=new XMLHttpRequest();
} else {
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4 && xmlhttp.status==200) {
if(xmlhttp.responseText == 'Error') alert('Error processing request. Please refresh the page and try again');
else if(xmlhttp.responseText != '') eval(responseFunction+"('"+xmlhttp.responseText+"')");
}
}
var now = new Date();
var url = "control/ajax.php?request="+requestName+"¶meters="+parameters+"×tamp"+now;
xmlhttp.open("GET",url,true);
xmlhttp.send();
}
An example of a failure, had the following variables set:
requestName: "save_marksheet_mark" responseFunction: "update_save_marksheet_mark" parameters: [60962,1284,5]
Is there something wrong with this code? Is there a reason why IE11 would throw an error with this code, in particular circumstances?
This question appears to be getting a lot of views, so just in case anybody was wondering, I solved this problem by using a setTimeout() on the original AJAX call. E.g:
setTimeout(function() {
ajaxRequest('save_mark','save_mark_completed',[60962,1284,5])
}, 1);
I'm assuming it's some kind of bug in IE. Just 1 millisecond was all it needed!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With