【问题标题】:Submit json response not read correctly提交 json 响应未正确读取
【发布时间】:2013-06-08 20:28:51
【问题描述】:

我有这个代码:

    sendData: function(){
        var me = this;
        this.getForm().submit({
            url: me.action,
            method: 'POST',
            success: function(form,action){
                if(action.result.success === true){
                    Ext.create('cp.view.ui.AlertOk',{mensaje:action.result.msg}).showDialog();
                    me.up('decoratorForm').close();
                    Ext.ComponentQuery.query('gestionPaciente')[0].getStore().load();                 
                }else{
                    Ext.create('cp.view.ui.AlertErr',{mensaje:action.result.msg}).showDialog();
                }
            }
        });
    } 

当操作成功时,'action.result.success'为真,并显示对话框。但是,当为假时,不显示对话框。返回的json字符串为:

{"success":false,"msg":"El dni ingresado ya existe y se encuentra 激活。”}

而编写 json 字符串的 PHP 代码是:

$m = array('success' => false, 'msg' => 'El dni ingresado ya existe y se encuentra activo.');
die(json_encode($m));

有什么想法吗? .

【问题讨论】:

    标签: json extjs submit response


    【解决方案1】:

    submit 调用的选项中尝试failure 回调。

    【讨论】:

    • 这真的有效吗?我不确定.. 我想也许只有在实际请求失败时才激活失败。
    • 是的,与Ajax.request相反,form submit decodes the response,根据成功值调用回调。
    猜你喜欢
    • 2021-10-08
    • 2018-05-23
    • 1970-01-01
    • 2012-01-07
    • 1970-01-01
    • 2013-03-11
    • 1970-01-01
    • 2023-04-02
    • 2016-03-28
    相关资源
    最近更新 更多