...

View Full Version : Resolved Aborting an AJAX request



H3X
01-19-2011, 06:10 AM
Hey all, I am using this AJAX function to perform an action when it is called:

function xmlhttpPost(strURL, cword) {
var xmlHttpReq = false;
var self = this;
if (window.XMLHttpRequest) {
self.xmlHttpReq = new XMLHttpRequest();
} else if (window.ActiveXObject) {
self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
}
self.xmlHttpReq.open('POST', strURL, true);
self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
self.xmlHttpReq.onreadystatechange = function() {
if (self.xmlHttpReq.readyState == 4) {
alert('hi');
}
}
self.xmlHttpReq.send('q='+cword);
}
This is working fine, however, I want any previous AJAX requests to be aborted before beginning the new AJAX request. I have searched, and I can't find anything specific to the current structure of the AJAX function I am using to get the job done.

What changes must I make in order to do this?

Thanks!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum