<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
$.ajax({
type: "POST",
contentType: "application/json",
url: "JqueryDemo.aspx/GetUserName",
data: "{}",
dataType: "json",
success: dd,
error: function(x, e) {
alert("e")
}
});
});
function dd(result) {
alert(result.d)
}
</script>
//[webmethod(enablesession = true)]//或[webmethod(true)]
[WebMethod]
public static string GetUserName()
{
return "234";
}
本文演示了如何使用jQuery AJAX方法从服务器获取用户名,并在成功或错误时进行响应。

447

被折叠的 条评论
为什么被折叠?



