ExtJS无法解码JSON消息

时间:2012-04-02 11:19:09

标签: c# javascript extjs

我正在使用ExtJS向服务器端发出Ajax请求,然后我想解析JSON响应并对其执行某些操作。

问题是我无法解码响应文本:

Ext.Ajax.request({
                                    url: 'Applications/GetFarmCounters.aspx',
                                    params: { farm: 'test', farmid: Ext.getCmp('farm_id').getValue() },
                                    success: function (result, request) {
                                        // result.responseText is here : {succes : true, message : 'test'}

                                        var jsonData = Ext.util.JSON.decode(result.responseText);

                                        Ext.MessageBox.alert('Success', 'Decode of stringData OK<br />jsonData.message= ' + jsonData.message);

                                    },
                                    failure: function (response, opts) {
                                        Ext.Msg.alert('Warning', 'Error!');
                                    }
                                });

但是,我没有在警告框中查看“测试”消息,而是在Chrome开发人员工具中收到此错误消息:“未捕获的SyntaxError:意外的令牌”

我做错了什么?

谢谢!

2 个答案:

答案 0 :(得分:2)

这是一个JSON问题

{
    "success": true,
    "message": "test"
}

应该是您返回的JSON。始终使用JSONLint

测试您的JSON

答案 1 :(得分:0)

似乎这个已知问题。 检查here,如果它解决了您的问题