ajax的简单使用
2016-12-05 本文已影响16人
飞天猪Pony
参数说明:
url:跳转的路径
data:要传的参数
type:类型(get、post)
success:成功
$.ajax({
url: "/usercenter/ModifyInfo",
data: {
id:2,
name:小王,
mobile:13200000000,
address:北京朝阳,
},
type:"POST",
success:function(e){
alert(e);
}
})
后台处理:
public int ModifyInfo(int? id,string name,string mobile,string address)
{
User user = db.User.Find(id);
user.Name = name;
user.Mobile = mobile;
user.Address = address;
db.SaveChanges();
return 1;
}