I want to get the text by entering any id in the textbox like 0, 1 or 2. It's not showing when I press the button Get by Id.
<script src="~/Scripts/jquery-1.10.2.min.js"></script>
<input type="text" name="name1" id="text1" value="" />
<input type="button" name="name2" id="btn1" value="Get by Id" />
<script>
$("#btn1").click(function () {
var id = $("#text1").val;
$.getJSON("/api/Customer/" + id, function (data) {
alert(data);
});
});
</script>
idhave the value you expect? Is the AJAX call made? What is the server's response? Please provide information about the problem. At least at a quick glance, you're not invoking theval()function properly. It should be$("#text1").val().