There's no such thing as a stupid question, but they're the easiest to answer.


Web Design & Development Web Design & Development
Search Search
Search for:
Tech Support Guy > > >

stopping ajax calls


cpscdave's Avatar
cpscdave cpscdave is offline
Member with 433 posts.
Join Date: Feb 2004
Experience: Intermediate
09-Jul-2010, 03:29 PM #1
stopping ajax calls
Hi all

I've written a function to do an autocomplete on some input forms
function getPartAutoComplete(str, field)
	ajax = getAjaxHandler();
	url = base + "parts/ajax_part_list/" + str +"/" + field;
	ajax.onreadystatechange = function(){
		if(ajax.readyState == 4){
	}"GET", url, true);
The problem is if the user types in a bunch of characters it does a bunch of searches that aren't actually used.

Say the user searches for drip.
There will be a search on dri and drip and the first one gets ignored.

Is there a way when it goes into the function to search for drip to kill hte dri search in progress?

It's not really an issue on this site, I'm more curious for myself
MMJ's Avatar
MMJ MMJ is offline
Senior Member with 3,625 posts.
Join Date: Oct 2006
10-Jul-2010, 05:33 AM #2
try ajax.abort
cpscdave's Avatar
cpscdave cpscdave is offline
Member with 433 posts.
Join Date: Feb 2004
Experience: Intermediate
10-Jul-2010, 11:17 AM #3
how can I tell when another ajax call has started?

There is no concept of static varibles inside of Javascript so each seperate call will have it's on unique ajax handler
As Seen On

BBC, Reader's Digest, PC Magazine, Today Show, Money Magazine

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.

Search Tech Support Guy

Find the solution to your
computer problem!

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Thread Tools

Similar Threads
Title Thread Starter Forum Replies Last Post
Advice on ajax calls and race conditions cpscdave Web Design & Development 4 10-Jun-2010 11:38 AM
Solved: PHP and AJAX Live search StevieJdelsim Web Design & Development 1 11-Mar-2010 04:18 AM
Solved: PHP / AJAX problem Nycris Web Design & Development 1 11-Jul-2009 01:36 PM
call of duty 4 server list Troglet Games 9 04-Jul-2008 06:47 AM
Solved: AJAX/PHP Drop-Down Edfrommars Web Design & Development 3 11-Jun-2008 11:39 AM

You Are Using: Server ID
Trusted Website Back to the Top ↑