382 posts
  • Has been part of the Envato Community for over 6 years
  • Has referred 1+ members
  • Has sold $10,000+ on Envato Market
  • Has collected 10+ items on Envato Market
+2 more
blabus says

Alright, for all you JavaScript experts out there, I’ve got an interesting problem I need to solve.

I have a search field on my web application, and that search field is used to search an external datasource through an API . I pass my query (the textbox value) and get back the XML results. Simple.

However, wanting to add that extra bit of sexiness :D , I want to have the results returned in realtime, as the user is typing (as opposed to having to type the whole search query, and then press a ‘Search’ button).

Now, I realize that I can hook into the keyDown/keyUp events of the textbox, BUT that introduces a new problem. The external API I ’m referencing doesn’t allow you to make more than one call per second (obviously to reduce server load, which I understand).

SO basically, I was wondering if anybody knows of a way to detect when the user has FINISHED entering their search term. Basically, what I want to do is detect a specified pause in text entry. So for example, after no text has been added/changed in the textbox for at least 3 seconds, we’ll assume the user has typed what they want to type, and then proceed to process that text (in this case, send it to the API for our results).

Anybody have any ideas? :)

426 posts
  • Has been part of the Envato Community for over 6 years
  • Has referred 10+ members
  • Has sold $5,000+ on Envato Market
  • Has been a beta tester for an Envato feature
+3 more
vasilios says

I think I know what you can try, but give me like ~10-15 minutes to finish this essay, and then I’ll try and see if what I was thinking would work. :)

(OT: Just noticed we have the same badges. :P)

426 posts
  • Has been part of the Envato Community for over 6 years
  • Has referred 10+ members
  • Has sold $5,000+ on Envato Market
  • Has been a beta tester for an Envato feature
+3 more
vasilios says

This seems to work (probably not the most practical). Try it out and see if that works. :)

http://pastie.org/647787

382 posts
  • Has been part of the Envato Community for over 6 years
  • Has referred 1+ members
  • Has sold $10,000+ on Envato Market
  • Has collected 10+ items on Envato Market
+2 more
blabus says

Awesome, thanks for the help! I’ll try it tomorrow to make sure it works, but it looks like it will (quite ingenious as a matter of fact :) )

Helpful Information

  • Please read our community guidelines. Self promotion and discussion of piracy is not allowed.
  • Open a support ticket if you would like specific help with your account, deposits or purchases.
  • Item Support by authors is optional and may vary. Please see the Support tab on each item page.

Most of all, enjoy your time here. Thank you for being a valued Envato community member.

Post Reply

Format your entry with some basic HTML. Read the Full Details, or here is a refresher:

<strong></strong> to make things bold
<em></em> to emphasize
<ul><li> or <ol><li> to make lists
<h3> or <h4> to make headings
<pre></pre> for code blocks
<code></code> for a few words of code
<a></a> for links
<img> to paste in an image (it'll need to be hosted somewhere else though)
<blockquote></blockquote> to quote somebody

:grin: :shocked: :cry: Complete List of Smiley Codes

by
by
by
by
by
by