I am trying to call SendInfo method by clicking on some label from codebehind file for aspx with jQuery.ajax. But all the time it goes to 'error' part, not success, and string isn't returning from method.
So tell me, please, what am i doing wrong here?
just started to learn ajax.
Index.aspx :
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<script type='text/javascript' src='../../Scripts/jquery-1.4.1.min.js'></script>
<script type="text/javascript" >
$(document).ready(function () {
$("#Result").click(function () {
$.ajax({
type: "POST",
url: "Index.aspx/SendInfo",
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (msg) {
$("#Result").text(msg.d);
},
error: function () {
$("#Result").text("adas");
}
});
});
});
</script>
<div id="Result">Click here for the time.</div>
</asp:Content>
Codebehind file :
public class Index : ViewPage
{
[WebMethod]
public static string SendInfo()
{
return "Info actually sended";
}
}