0
ASPX页面jQuery的AJAX方法不使用的WebMethod
<script>
$(document).ready(function() {
$.ajax({
type: "POST",
url: "WebForm1.aspx/GetData",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (response) {
$("#Content").text(response.d);
},
failure: function (response) {
alert(response.d);
}
});
});
</script>
</head>
<body>
<form id="frm" method="post">
<div id="Content">
</div>
</form>
</body>
</html>
代码背后
public static string GetData()
{
return "This string is from Code behind";
}
我想用ajax这个功能,而无需使用 “WEBMETHOD”。即GetData()
方法,我想在我的.aspx页面中显示而不使用Web服务。
你需要WebMethod属性。 – Zaki