Go Back   CodingForums.com > :: Client side development > JavaScript programming > Ajax and Design

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-19-2011, 05:10 AM   PM User | #1
H3X
New Coder

 
Join Date: Nov 2008
Posts: 90
Thanks: 30
Thanked 0 Times in 0 Posts
H3X is an unknown quantity at this point
Aborting an AJAX request

Hey all, I am using this AJAX function to perform an action when it is called:
Code:
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!

Last edited by H3X; 01-19-2011 at 06:45 AM..
H3X is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 04:12 AM.


Advertisement
Log in to turn off these ads.