Advertisement

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

Advertisement

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 427 posts.
THREAD STARTER
 
Join Date: Feb 2004
Experience: Intermediate
09-Jul-2010, 04:29 PM #1
stopping ajax calls
Hi all

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

EG:
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, 06:33 AM #2
try ajax.abort
cpscdave's Avatar
cpscdave cpscdave is offline
Member with 427 posts.
THREAD STARTER
 
Join Date: Feb 2004
Experience: Intermediate
10-Jul-2010, 12:17 PM #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
WELCOME TO TECH SUPPORT GUY!

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.


(clock)
THIS THREAD HAS EXPIRED.
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 12:38 PM
Solved: PHP and AJAX Live search StevieJdelsim Web Design & Development 1 11-Mar-2010 05:18 AM
Solved: PHP / AJAX problem Nycris Web Design & Development 1 11-Jul-2009 02:36 PM
call of duty 4 server list Troglet Games 9 04-Jul-2008 07:47 AM
Solved: AJAX/PHP Drop-Down Edfrommars Web Design & Development 3 11-Jun-2008 12:39 PM

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