不是json格式的.
1 $.ajax({ 2 type: "Post", 3 url: "/activity/AuditAdd", 4 data: { UserName: $('#userName').val(), UserCertId: $('#userCertId').val(), BankInfo: $("#province_AreaCode").find("option:selected").text() + $("#city_AreaCode").find("option:selected").text() + $('#bankName').val() + $('#subbranchName').val(), CardID: $('#confirm').val(), Phone: $('#phone').val(), Email: $('#email').val() }, 5 dataType: "json", 6 success: function (r) { 7 if (r.success == true) { 8 $('#submitMsg').show(); 9 $('#application').hide(); 10 $(":text").val(""); 11 } else { 12 alert("存在相同的身份证号码"); 13 return false; 14 } 15 16 }, 17 error: function (err) { 18 alert("提交失败"); 19 } 20 });
不管那么多了,这是工作上的代码.
其中 url是方法的地址
data是要传过去的数据
再好像..没什么需要解释的了
贴下后台代码(mvc4):
1 public ActionResult AuditAdd(Product_ActivityUsers model, string UserName, string UserCertId, string BankInfo, string CardID, string Phone, string Email, string Province, string City) 2 { 3 model.ID = IdentityCreator.NextIdentity; 4 model.ContactName = UserName; 5 model.UserCertId = UserCertId; 6 model.UserBankCardId = CardID; 7 model.ContactPhone = Phone; 8 model.ContactEmail = Email; 9 model.IsAvailable = 0; 10 model.IsDel = 0; 11 model.AddDate = DateTime.Now; 12 model.IsSync = 0; 13 string str = BankInfo; 14 StringBuilder sb = new StringBuilder(str); 15 sb.Replace("请选择城市", ""); 16 model.UserBankInfo = sb.ToString().Trim(); 17 if (!o_Res.IsExistProduct_ActivityUsersByCertId(UserCertId)) 18 { 19 if (o_Res.CreateProduct_ActivityUsers(model)) 20 { 21 return Json(new MLJsonResult { msg = Resources.Message.SaveSuccess, success = true }); 22 } 23 } 24 return Json(new MLJsonResult { msg = Resources.Message.SaveFailure, success = false }); 25 }
也没什么刻意需要解释的,以后看见这些代码就知道是什么意思了.