ajax访问 aspx.cs后台

--前台
$.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";
}



 

posted @ 2016-08-01 10:15  fightingyy  阅读(407)  评论(0编辑  收藏  举报