<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#btn").click(function() {
var val = "Hi";
$.ajax ({
url: "1.php?id",
data: { id : val }
});
});
});
</script>
<form name="numbers" id="numbers">
<input type="text" name="id" id="btn">
<input type="text">
</form>
This code is for click event but i want onchange event like on select option. Can anybody suggest me how to add onchange event on this ajax code? Thank you in advance.
$(document).ready(function(){
$("#btn").on("change", function() {
var val = "Hi";
$.ajax ({
url: "1.php?id",
data: { id : val }
});
});
});
<input type="text" name="id" id="btn" onchange="ajaxfunction()" />
<script>
function ajaxfunction()
{
enter ajax code here
}
</script>
You can try using keyup like so.
$(document).ready(function () {
$("#btn").keyup(function () {
var val = $(this).val();
$.ajax({
url: "1.php?id",
data: { id: val }
});
});
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.