Use of "setTimeout()" in my jQuery Expression

Posted by Aaron Salazar on Stack Overflow See other posts from Stack Overflow or by Aaron Salazar
Published on 2010-03-26T14:59:57Z Indexed on 2010/03/26 15:03 UTC
Read the original article Hit count: 471

Filed under:
|
|

I'm trying to add the JavaScript function setTimeout() to my jQuery expression. Without the setTimeout() my function loads a partial view with updated information when I enter text into my textbox. But, it loads the information with every keystroke. My logic is that if I can put in a timer then when the user stops typing, a second later the data is updated.

As you can see I tried to put a setTimer() in but it doesn't seem to be working.

$(function() {
    $('#DocId').live('keyup', function() {
        setTimeout(var styleValue = $(this).val();
        $('#tableContent').load(
        '/CurReport/TableResults', 
        { style: $(this).val()}), 1000);

    }),
});

Thank you,

Aaron

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about settimeout