javascript - How do you send an ajax request every time that a form input field changes? -


for example, there input field. every time user types key field, sends ajax request whatever text in input, , it. i've looked change , keyup functions in jquery, when try them in jsfiddle don't anything. there standard way of doing type of operation? know common validations , stuff.

<form>     <input id="test" type='text' >     <input type="submit" value="asdf"> </form>  $('input').on("change",(function(e){     alert("hello"); }); 

the effect going game www.sporcle.com/games/g/nflteams#

you can type in text , if within set of correct answers table update show answer. never have submit. how suppose achieved effect?

it seemed me must querying database every time user enters key, see if correct answer. if update table display answer. other ways this?

sending request on each change bad, delay ajax on last change

var changetimer = false;  $("your inputs").on("your change event",function(){         if(changetimer !== false) cleartimeout(changetimer);         changetimer = settimeout(function(){             /* ajax here */             changetimer = false;         },300); }); 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -