<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";
}