I am creating a hospital ERP project for my office. I have already added some features. in this time I need jquery ajax request for my project. I'm trying more but I am not a success this webform. so I need help expert person. My Code Not working asp.net webform jquery ajax request.
Here is my code
[System.Web.Services.WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public Employee GetByEmployeeId(int Id)
{
Employee employee = new Employee();
return employee;
}
<script src="Scripts/jquery-2.2.4.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$('#saveButton').click(function () {
debugger;
$.ajax({
type: 'POST',
url: 'Test.aspx/GetByEmployeeId',
data: '{Id: ' + 1 + '}',
success: function (respons) {
debugger;
alert('ok');
},
error: function () {
alert('fail')
}
})
})
})
</script>
<div class="form-group">
<asp:Label runat="server" For="nametextBox">Name:</asp:Label>
<asp:TextBox runat="server" ID="nametextBox" CssClass="form-control">
</asp:TextBox>
</div>
<div class="form-group">
<button type="submit" class="btn btn-primary" id="saveButton">Save</button>
</div>
I am trying this but not working