关于怎么用jQuery来获取mvc中返回值为JsonResult的值
2017-12-02 · 百度知道合伙人官方认证企业
育知同创教育
1【专注:Python+人工智能|Java大数据|HTML5培训】 2【免费提供名师直播课堂、公开课及视频教程】 3【地址:北京市昌平区三旗百汇物美大卖场2层,微信公众号:yuzhitc】
向TA提问
关注
展开全部
//code[jquery]
<script type="text/javascript">
var userId = '@User.UserID';
#("$Btn_Submit").click( function () {
var _self = this;
var postdata = {};
postdata.workroomid = _self.WorkroomId.val();
//邮箱reg
var regex1 = new RegExp('^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@("@")([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$');
//电话reg
var regex2 = /^1[3|5|8][0-9]\d{4,8}$/;
if (!/^\d+$/.test(postdata.workroomid)) {
dlg.Msg.Err("团队ID不正确,请重新输入!");
//alert(postdata.workroomid);
return;
}
if (postdata.workroomid != "") {
$("#roomspan").hide();
}
postdata.email = _self.Email.val();
if (postdata.email != "") {
//dlg.Msg.Err("请填写E-mail");
$("#emailspan").hide();
};
if (!postdata.email.match(regex1)) {
dlg.Msg.Err("邮箱格式不正确,请重新输入!");
$("#E-mail").focus();
return;
}
postdata.period = _self.Period.val();
postdata.periodname = _self.Period.find("option:selected").text();
postdata.subject = _self.Subject.val();
postdata.subjectname = _self.Subject.find("option:selected").text();
postdata.tel = _self.Tel.val();
if (postdata.tel != "") {
//dlg.Msg.Err("请填写联系电话");
$("#telspan").hide();
};
if (!postdata.tel.match(regex2)) {
dlg.Msg.Err("电话格式不正确,请重新输入!");
$("#Tel").focus();
return;
}
//跟着感觉走的话,方法应该放到这个post里面才对,但我不知该怎么综合上面两个方法,不可能post里面再放个post吧?
$.post("/admin/teachercenter/applyjoinworkroom", postdata, function (ret) {
if (ret == 0) {
dlg.Msg.Cor("申请成功!");
} else if (ret == 1) {
dlg.Msg.Cor("已经提交申请!");
} else {
dlg.Msg.Err("申请失败!");
}
});
}
)
</script>
页面html:
<div id="myjoin" class="tabCon">
<table class="com-tb mt20">
<colgroup>
<col>
<col class="wp10">
<col class="wp10">
<col class="wp10">
<col class="wp15">
<script type="text/javascript">
var userId = '@User.UserID';
#("$Btn_Submit").click( function () {
var _self = this;
var postdata = {};
postdata.workroomid = _self.WorkroomId.val();
//邮箱reg
var regex1 = new RegExp('^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@("@")([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$');
//电话reg
var regex2 = /^1[3|5|8][0-9]\d{4,8}$/;
if (!/^\d+$/.test(postdata.workroomid)) {
dlg.Msg.Err("团队ID不正确,请重新输入!");
//alert(postdata.workroomid);
return;
}
if (postdata.workroomid != "") {
$("#roomspan").hide();
}
postdata.email = _self.Email.val();
if (postdata.email != "") {
//dlg.Msg.Err("请填写E-mail");
$("#emailspan").hide();
};
if (!postdata.email.match(regex1)) {
dlg.Msg.Err("邮箱格式不正确,请重新输入!");
$("#E-mail").focus();
return;
}
postdata.period = _self.Period.val();
postdata.periodname = _self.Period.find("option:selected").text();
postdata.subject = _self.Subject.val();
postdata.subjectname = _self.Subject.find("option:selected").text();
postdata.tel = _self.Tel.val();
if (postdata.tel != "") {
//dlg.Msg.Err("请填写联系电话");
$("#telspan").hide();
};
if (!postdata.tel.match(regex2)) {
dlg.Msg.Err("电话格式不正确,请重新输入!");
$("#Tel").focus();
return;
}
//跟着感觉走的话,方法应该放到这个post里面才对,但我不知该怎么综合上面两个方法,不可能post里面再放个post吧?
$.post("/admin/teachercenter/applyjoinworkroom", postdata, function (ret) {
if (ret == 0) {
dlg.Msg.Cor("申请成功!");
} else if (ret == 1) {
dlg.Msg.Cor("已经提交申请!");
} else {
dlg.Msg.Err("申请失败!");
}
});
}
)
</script>
页面html:
<div id="myjoin" class="tabCon">
<table class="com-tb mt20">
<colgroup>
<col>
<col class="wp10">
<col class="wp10">
<col class="wp10">
<col class="wp15">
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询