I tried to get data from web method in asp page to ajax jquery method. But Ajax method is not firing. And not even showing any error message. Please help me
[WebMethod]
public static string Sample(string data)
{
string strStatus = data+ "hello world";
return strStatus;
}
javascript
$(document).ready(function () {
$("#btnSubmit").click(function (e) {
var data = $("#<%=txtsample.ClientID%>").val();
$.ajax({
type: "POST",
url: '<%=ResolveUrl("~/Default2.aspx/Sample")%>',
data: '{data:' + data + '}',
contentType: "application/json; charset=utf-8",
datatype: "json",
success: function (response) {
$("#<%=lblMsg.ClientID%>").text(response.data);
},
failure: function (response) {
$("#<%=lblMsg.ClientID%>").text(response.data);
},
error: function (response) {
$("#<%=lblMsg.ClientID%>").text(response.data);
}
});
});
});