【发布时间】:2015-07-13 19:10:54
【问题描述】:
我面临以下问题:每当我点击button 时,alert 会显示undefined。
网络方式:
[WebMethod]
public static string getTest()
{
return "testing success";
}
Ajax 脚本
<script type="text/javascript">
function getTest() {
$.ajax({
type: "POST",
url: "main.aspx/getTest",
data: "{}",
datatype: "json",
contenttype: "/application/json; charset=utf-8",
success: function (msg) {
alert(msg.d);
},
error: function (data) {
}
});
}
</script>
【问题讨论】:
-
contenttype: "/application/json; charset=utf-8" 从应用程序的开头删除 /。
标签: asp.net ajax json undefined