I have the following javascript:
<script type="text/javascript">
$(document).ready(function() {
$.ajax({
type: "POST",
url: "WebForm3.aspx/sayHello",
contentType: "application/json; charset=utf-8",
data: "{}",
dataType: "json",
success: AjaxSucceeded,
error: AjaxFailed
});
});
function AjaxSucceeded(result) {
alert(result.d);
}
function AjaxFailed(result) {
alert(result.status + ' ' + result.statusText);
}
</script>
I have the following in my code behind.
[WebMethod]
public static string sayHello()
{
return "hello";
}
This works and shows hello.
Now, if I do:
[WebMethod]
public static string sayHello(string args)
{
return "hello";
}
Then I get internal server error 500 as a reply.
How can I change this to allow me to send actual data to the server side?
Well,
This works: