Here's what I would do.  Hope this makes sense:

 [0] On key down, set some global state variable to true.

 [1] On key up, set the state variable to false.

 [1a] Then use setTimeout() to have it call a new function in 1 second
(adjust for usability).

 [2] Your new function will look to to see if the state variable from
[1] is still false.  If it is false, do your ajax.  If it is not
false, do nothing.

On Jan 14, 8:20 pm, Info <i...@vglservices.com> wrote:
> Hi There,
> I have some code (below) that does an ajax call on keyup of a form
> field. It works great.....but I really want to pause the call for 1
> sec after they do the keyup to allow them to put in some text. Is
> there a way to take this code and do that?
>
> $(document).ready(function(){
>         $('#search').keyup(function() {
>                 var searchVal = $('#search').val();
>                 $.ajax({
>                         type: 'GET',
>                         url: 'qryget_customers.php',
>                         data: 'search=' + searchVal,
>                         dataType: 'html',
>                         beforeSend: function() {
>                                 $('#search_slips').html('<img 
> src="../common/images/ajax-
> loader.gif" alt="loading..." />');
>                         },
>                         success: function(response) {
>                                 $('#search_slips').html(response);
>                         }
>                 });
>         });
>
> });

Reply via email to