有那个大神有.net的AJAX前后台的数据交互案例啊,能不能发给我一份啊,我没有c币啊。扣扣号(1154031651)
function freshdata() {
//Ajax获取数据
var xhr = false;
xhr = new XMLHttpRequest();
xhr.open("POST", "GetData.aspx?case=" + document.getElementById("input2").value, true......
答案就在这里:AJAX 前后台数据交互
----------------------你好,人类,我是来自CSDN星球的问答机器人小C,以上是依据我对问题的理解给出的答案,如果解决了你的问题,望采纳。
前台aspx页面:
<script type="text/javascript>
$(function(){
$.ajax({
type: "Post",
async: true,
url: "UserList.aspx/DeleteUser",
data: "{'Key':'" + userId + "'}",
contentType: "application/json;charset=utf-8",
dataType: "json",
success: function (res) {
alert('删除成功!');
window.location.href = window.location.href;
},
error: function (d, c, e) {
}
});
});
</script>
后台cs文件:
[WebMethod]
public static string DeleteUser(string Key)
{
string tag = "F";
GGJ_Sys_Users user = users_bll.GetModel(int.Parse(Key));
user.DeleteUserID = 2;
user.DeleteDate = DateTime.Now;
user.DeleteMark = 1;
try
{
users_bll.Update(user);
tag = "T";
}
catch (Exception)
{
tag = "F";
}
return tag;
}
或者你使用ajaxPro2页可以,很多方法