首页 新闻 会员 周边

form 表单 ajaxSubmit 提交后接收不到返回值

0
悬赏园豆:20 [已解决问题] 解决于 2018-03-06 10:30

前台代码

$("#formSave").ajaxSubmit({

success: function (data) {

ShowMsg(data.message)
if (data.success) {
window.location.href = "/CouponManage/BusinessCoupon/List";
}
},
error: function (data) {
ShowMsg(data.message);
}
});

后台代码

public JsonResult UpdateSave()
{

Guid guid = new Guid(Request["CouponGuid"]);
string Title = Request["title"];
string Detial = Request["desc"];
string msg = "";
CouponLogic bll = new CouponLogic(this.OpertorGuid);
Coupon coup = new Coupon();
coup.Guid = guid;
coup.Title = Title;
coup.Description = Detial;

bool flag = bll.UpdateCoupon(UserAccount, ChainStoreGuid, coup, out msg);

return Json(new { success = flag, msg = msg });

}

结果直接在浏览器里面输出了 

{"success":true,"message":"修改成功!"}

 

ajax提交哪里没有办法处理结果

似水阳光的主页 似水阳光 | 初学一级 | 园豆:109
提问于:2018-03-06 09:01
< >
分享
最佳答案
1
   $("#formSave").ajax({
            type: 'post', // 提交方式 get/post
            url: 'your url', // 需要提交的 url
            data: {
                'title': title,
                'desc': desc,
                'CouponGuid':CouponGuid
            },
            success: function(data) { // data 保存提交后返回的数据,一般为 json 数据
                // 此处可对 data 作相关处理
                alert('提交成功!');
            }
            $(this).resetForm(); // 提交后重置表单
        });
收获园豆:20
悟行 | 专家六级 |园豆:12559 | 2018-03-06 09:22

还是一样的在浏览器中直接输出了结果

似水阳光 | 园豆:109 (初学一级) | 2018-03-06 09:39

@似水阳光: 把上面的ajaxSubmit换成ajax

悟行 | 园豆:12559 (专家六级) | 2018-03-06 09:45
其他回答(2)
0

找到问题了,是这个方法之外的代码影响到了

似水阳光 | 园豆:109 (初学一级) | 2018-03-06 10:29
0

可以自己封装个.

function ajax(url, data, asycn, callback, fallcallback) {
        $.ajax({
            url: url,//要掉用的接口
            type: "POST",//请求方式
            async: asycn,//同步异步false为同步
            dataType: "json",//传输类型
            data: data,//参数
            success: function (data) {//成功回调 data就是后台返回的数据
                callback(data)
            },
            error: function () {
                fallcallback()//失败回调
            }
        })
}
DanBrown | 园豆:1321 (小虾三级) | 2018-03-06 10:40
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册