I am using long polling in my project. When the project is running, one of the long polling requests is waiting response from the server. Now, when the user generates a new template, then I have to abort the previous long polling call and run the new one.
Aborting in IE gives the error
couldn't complete the operation due to error c00c023f
I don't want to use the Jquery and aborting the previous request is very important. I tried Try and Catch to prevent from showing this error but it didn't work out.
I am also using the abort when the normal request(not polling request) request doesn't reach the server after few seconds, then I abort the old request and send new one.
I store the xmlHttp object in array for each request.
like: array_XMLHttp.push(request1);
I abort it like: array_XMLHttp[index_of_request].abort();
I couldn't find any solution for IE9, while it works perfect on all other browsers.
UPDATE:
I always check the status and readyState for the XMLHttp Object as below:
function checkResponse(xmlHttp){
xmlHttp.onreadystatechange=function(){
if(xmlHttp.readyState==4){
if(xmlHttp.status==200){
// Request received
}
}
}
}
Here is how I start the request
// to start new XmlHttp object
var xmlHttp=crXH();
// add the request to array to be aborted later if required
array_XMLHttp.push(request1);
// initiate the callback
checkResponse(xmlHttp);
//send the request to server
send(xmlHttp);
When I abort:
// The problem now the callback function will not read (undefined) the new property added to the aborted object.
array_XMLHttp[index_of_request].aborted = true;
array_XMLHttp[index_of_request].abort();
Thank you for your help!
.readyStateor.status. The work-around is to set your own.abortedproperty when you abort and check that first to avoid checking the other exception-throwing properties on an abort..abortedproperty on thexmlHttpobject when you call.abort()which you have to have access to at that time and you also have access to incheckResponse()which are the two places you need it.