私は次の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>
私のコードビハインドには次のものがあります。
[WebMethod]
public static string sayHello()
{
return "hello";
}
これは機能し、こんにちはを示します。
今、もしそうなら:
[WebMethod]
public static string sayHello(string args)
{
return "hello";
}
その後、応答として内部サーバー エラー 500 が返されます。
これを変更して実際のデータをサーバー側に送信できるようにするにはどうすればよいですか?