Button's click event fires, but can't trigger ajax call
In a page of my asp.net mvc website, I load data into a jqGrid when the page loads, works perfectly without any problem.
Now I added a button for users to search employees by last name. The click event fires, because I can see my alert("Last name is " + lastName) popup. But the ajax call is ignored.
<input type="text" id="keyword" />
<input type="button" id="search" value="Search" />
$(document).ready(function () {
$("#search").click(function () {
var keyword = $.trim($("#keyword").val());
//alert("Last name is " + keyword);
$.ajax({
url: '/Path/To/WebMethod/',
dataType: 'json',
type: 'POST',
success: function (result) {
...
...
});
As I said, the alert shows up just fine (I have commented it out for this post). But the ajax call that follows never gets triggered off.
I searched and also tried $("#button").on("click", function() { //blah blah }); It still does not work.