dcsimg
www.webdeveloper.com
Results 1 to 5 of 5

Thread: web service after 1 second of keyboard inactivity

  1. #1
    Join Date
    Jun 2010
    Posts
    2

    Exclamation web service after 1 second of keyboard inactivity

    Hi,
    in a my application, I have an input text and I have to call a web service with the text inserted as a query.
    I would that this web service will start after 1 second of keyboard inactivity. How can I do it?

    At the moment the service start after a number of words and every new word inserted.

    Thanks.

  2. #2
    Join Date
    Dec 2003
    Location
    Bucharest, ROMANIA
    Posts
    15,428
    What do you mean by "text inserted"? Inserted where? From where? Can you be more descriptive, please?

  3. #3
    Join Date
    Jun 2010
    Posts
    2
    I have a text box in which the user can insert a string that the web service must process.
    Now this web service starts every word that user key in the text box.
    I would like that the web services will start after 1 or 2 seconds after tha last digit.

  4. #4
    Join Date
    Dec 2005
    Posts
    2,984
    Now this web service starts every word that user key in the text box.
    Then using a timer of 'keyboard inactivity' would be silly, wouldn't it? What if somebody stopped mid-word to think about something for a second, go to the bathroom, turn off the stove, etc?

    With this in mind, you might want to rethink the design of the application. Maybe you want to add a submit button? Maybe you want to call the service after a certain number of characters have been entered, maybe after you've captured a certain keystroke (e.g. enter, space, etc).

    I think it's a terrible idea to make a server request based on the fact that somebody stopped typing for 1-2 seconds, if you don't know that they're actually finished typing or not.


    Also, for interests sake, what kind of application are you trying to make?

  5. #5
    Join Date
    Mar 2010
    Posts
    2,803
    Quote Originally Posted by lc81 View Post
    I have a text box in which the user can insert a string that the web service must process.
    Now this web service starts every word that user key in the text box.
    I would like that the web services will start after 1 or 2 seconds after tha last digit.
    I assume you have a function or whatever that checks if the user has inputed "that last digit" and not merely paused for some reason.

    If so, you could use the function as an onkeyup event handler to check if the last digit has been entered before submitting the query string from that function using javascript.

    Or if you must have a 1 - 2 second delay after the last digit has been entered, you could use setTimeout() in that function to delay the query string submission by whatever time period you like after the last digit has been entered.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles