Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
  1. #1
    New Coder
    Join Date
    Nov 2008
    Thanked 0 Times in 0 Posts

    Aborting an AJAX request

    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) {
    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?

    Last edited by H3X; 01-19-2011 at 07:45 AM.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts