I am trying to use the simple ajax script to webmethod as follows:
<script type="text/javascript">
$(document).ready(function () {
$("#btnretreive").click(function () {
$.ajax({
type: "POST",
url: "Default.aspx/Gettext",
data: {inputtext: $('#sometext').val()},
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(msg) {
$("#Result").text(msg.d);
}
});
});
});
</script>
And this is my webmethod:
<WebMethod()> _
Public Shared Function Gettext(ByVal inputtext As String) As String
Return inputtext
End Function
Here is my HTML part:
<input id="sometext" type="text" />
<input id="btnretreive" type="button" value="button" />
<div id="Result"></div>
Now my problem is I'm unable to send the input text and receive it back.Can anyone point out the mistake I'm doing here.