首页 > 技术文章 > ajax访问 aspx.cs后台

momjs 2016-08-01 10:15 原文

--前台
$.ajax({ 
type: "POST", 
contentType: "application/json", 
url: "WebForm2.aspx/GetUserName", 
data: "{}", 
dataType: "json", 
success: function(){.......} 
}); 

 

--list集合

$.ajax({
type: "POST",
contentType: "application/json",
url: "DeHx.aspx/GetUserName",
data: "", // data:"{uid:"+str+"}",
dataType: "json",
success: function(data){
$.each(data, function (key, val) {
var te = eval(data[key]);
alert(te);
});
}
});


--后台

[WebMethod(EnableSession = true)]
public static string GetUserName()  //(string  uid)
{
return "123";
}



 

推荐阅读