Last active
December 16, 2015 07:49
-
-
Save jsangilve/5401611 to your computer and use it in GitHub Desktop.
Simple jQuery snippet for input with XMLHTTPRequest (Ajax)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(function () { | |
var timer; | |
$('#id_input').keyup(function() { | |
clearTimeout(timer); | |
var val = this.value | |
var ms = 1000 | |
timer = setTimeout(function() { | |
getSomething(val) | |
}, ms) | |
}); | |
}) | |
function getSomething(param) { | |
var url = 'http://mysite.com/getsomething' | |
$.get(url, {parameter: param}, function(data) { | |
doSomething(data) | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment