ExtJS:属性列表后缺少 } 但我没有看到任何代码错误

发布于 2024-09-09 03:43:12 字数 3700 浏览 0 评论 0原文

加载失败 -- 参数:[对象 api=对象,对象请求=对象读取器=对象范围=对象,对象 tId=0 状态=200 statusText=OK,语法错误:在属性列表之后丢失 } 消息=丢失 } 在属性列表之后]

I通过向我的商店添加异常来得到该错误,但在我的代码中没有看到任何真正的错误......也许另一双眼睛会有所帮助。

php:

 case 'messages':
                    if(isset($_SESSION['id'])){
            $stmt = $dbh->prepare("Select ID, ReceivedAt, Message from SystemEvents Limit 100");
                            $stmt->execute();

            while($tmp = $stmt->fetch()){
                $y .= '{"ID":"'.$tmp['ID'].'","ReceivedAt":"'.$tmp['ReceivedAt'].'","Message":"'.$tmp['Message'].'"},';
            }
            $y = trim($y,',');
            if(isset($_REQUEST['callback'])){
                echo $_REQUEST['callback'].'({"dates":['.$y.']});';
            }else{
                echo '{"dates":['.$y.']}';
            }
        }else{
            if(isset($_REQUEST['callback'])){
                                    echo $_REQUEST['callback'].'({success: false, data{"error_title": "Error", "errormsg": "Cannot display dates"}})';
                            }
                            else{
                                    echo '{success: false, data{"error_title": "Error", "errormsg": "Cannot display dates"}}';
                            }
                    }
            break;

extjs:

Ext.onReady(function(){

var logStore = new Ext.data.JsonStore({
    autoLoad: true,
    url: 'inc/interface/config.php?list=messages',
    root: 'dates',
    idProperty: 'ID',
    fields: ['ID', 'ReceivedAt', 'Message'],
    listeners: {
                loadexception: function() {
                    console.log('load failed -- arguments: %o', arguments);
                }
        }
}); 

var dateStore = new Ext.data.JsonStore({
    autoLoad: true,
    url: 'inc/interface/config.php?list=date_options',
    root: 'dates',
    idProperty: 'ID',
    fields: ['ID', 'ReceivedAt'],
    listeners: {
                loadexception: function() {
                    console.log('load failed -- arguments: %o', arguments);
                }
        }
});

var dateSelect = new Ext.form.DateField({
    fieldLabel: 'Pick a date',
    width: 190,
    align: 'center',
    frame: true
});

var dateCombo = new Ext.form.ComboBox({
    store: dateStore,
    mode: 'local',
    valueField: 'ID',
    displayField: 'ReceivedAt',
    editable: false,
    emptyText: 'Select a Date',
    width: 250,
    listeners:{
        activate: function(){
            dateStore.reload();
        }
    }
});

var searchField = new Ext.form.TextField({
    fieldLabel: 'Search Criteria',
    emptyText: 'Search....',
    width: 190, 
    frame: true

});

var searchButton = new Ext.Button({
    text: 'Search',
});

var clearButton = new Ext.Button({
    text: 'Clear',
    tooltip: 'Clears all your search data'
});

var searchPanel = new Ext.Panel({
    layout: 'form',
    region: 'east',
    width: 300,
    collapsible: true,
    alignButton: 'right',
    title: "Search Panel",
    items: [dateSelect, dateCombo, searchField],
    buttons: [clearButton, searchButton]
});


var logGrid = new Ext.grid.GridPanel({
    region: 'center',
    store: logStore,
    colModel: new Ext.grid.ColumnModel({
        columns: [{
            id: 'received',
            header: 'Received',
            dataIndex: 'ReceivedAt',
            width: 250
        },{
            id: 'message',
            header: 'Logs',
            dataIndex: 'Message',
            width: 750
        }]
    }),
});


var mainViewport = new Ext.Viewport({
    layout: 'border',
    items: [logGrid, searchPanel]
});

});

我不认为发布我的 php 的其余部分是相关的,因为它一切正常,但希望有人能发现我的坏眼睛无法发现的东西。

load failed -- arguments: [Object api=Object, Object request=Object reader=Object scope=Object, Object tId=0 status=200 statusText=OK, SyntaxError: missing } after property list message=missing } after property list]

I got that error by adding an exception to my store but don't see any real error in my code...maybe another set of eyes will help.

php:

 case 'messages':
                    if(isset($_SESSION['id'])){
            $stmt = $dbh->prepare("Select ID, ReceivedAt, Message from SystemEvents Limit 100");
                            $stmt->execute();

            while($tmp = $stmt->fetch()){
                $y .= '{"ID":"'.$tmp['ID'].'","ReceivedAt":"'.$tmp['ReceivedAt'].'","Message":"'.$tmp['Message'].'"},';
            }
            $y = trim($y,',');
            if(isset($_REQUEST['callback'])){
                echo $_REQUEST['callback'].'({"dates":['.$y.']});';
            }else{
                echo '{"dates":['.$y.']}';
            }
        }else{
            if(isset($_REQUEST['callback'])){
                                    echo $_REQUEST['callback'].'({success: false, data{"error_title": "Error", "errormsg": "Cannot display dates"}})';
                            }
                            else{
                                    echo '{success: false, data{"error_title": "Error", "errormsg": "Cannot display dates"}}';
                            }
                    }
            break;

extjs:

Ext.onReady(function(){

var logStore = new Ext.data.JsonStore({
    autoLoad: true,
    url: 'inc/interface/config.php?list=messages',
    root: 'dates',
    idProperty: 'ID',
    fields: ['ID', 'ReceivedAt', 'Message'],
    listeners: {
                loadexception: function() {
                    console.log('load failed -- arguments: %o', arguments);
                }
        }
}); 

var dateStore = new Ext.data.JsonStore({
    autoLoad: true,
    url: 'inc/interface/config.php?list=date_options',
    root: 'dates',
    idProperty: 'ID',
    fields: ['ID', 'ReceivedAt'],
    listeners: {
                loadexception: function() {
                    console.log('load failed -- arguments: %o', arguments);
                }
        }
});

var dateSelect = new Ext.form.DateField({
    fieldLabel: 'Pick a date',
    width: 190,
    align: 'center',
    frame: true
});

var dateCombo = new Ext.form.ComboBox({
    store: dateStore,
    mode: 'local',
    valueField: 'ID',
    displayField: 'ReceivedAt',
    editable: false,
    emptyText: 'Select a Date',
    width: 250,
    listeners:{
        activate: function(){
            dateStore.reload();
        }
    }
});

var searchField = new Ext.form.TextField({
    fieldLabel: 'Search Criteria',
    emptyText: 'Search....',
    width: 190, 
    frame: true

});

var searchButton = new Ext.Button({
    text: 'Search',
});

var clearButton = new Ext.Button({
    text: 'Clear',
    tooltip: 'Clears all your search data'
});

var searchPanel = new Ext.Panel({
    layout: 'form',
    region: 'east',
    width: 300,
    collapsible: true,
    alignButton: 'right',
    title: "Search Panel",
    items: [dateSelect, dateCombo, searchField],
    buttons: [clearButton, searchButton]
});


var logGrid = new Ext.grid.GridPanel({
    region: 'center',
    store: logStore,
    colModel: new Ext.grid.ColumnModel({
        columns: [{
            id: 'received',
            header: 'Received',
            dataIndex: 'ReceivedAt',
            width: 250
        },{
            id: 'message',
            header: 'Logs',
            dataIndex: 'Message',
            width: 750
        }]
    }),
});


var mainViewport = new Ext.Viewport({
    layout: 'border',
    items: [logGrid, searchPanel]
});

});

I don't think posting the rest of my php would be relevant since it all works but hopefully someone can spot something that my bad eyes cannot.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

無處可尋 2024-09-16 03:43:12

我在这里看到一个额外的逗号:

var searchButton = new Ext.Button({
    text: 'Search',
});

也在 LogGrid 上。可能就是这样

编辑:如果出现错误,从 PHP 发回的响应看起来不会是有效的 JSON data{"error_title" 是错误的,应该是 data:{" error_titel"

你真的应该看看在 PHP 中构建对象/数组并使用 json_encode 回显它们,而不是手动构建 JSON。

I see an extra comma here:

var searchButton = new Ext.Button({
    text: 'Search',
});

Also on the LogGrid. That might be it

EDIT: The response sent back from PHP does not look like it will be valid JSON if there is an error data{"error_title" is wrong, should be data:{"error_titel"

You really should look at building objects/arrays in PHP and echo these using json_encode instead of building JSON manually.

小嗷兮 2024-09-16 03:43:12

顺便说一句:为了找到杂散的逗号,我使用以下模式进行搜索:

\,\s*(}|])

这可以节省大量时间,特别是因为不同的浏览器比其他浏览器对错放的逗号更强大。

BTW: To find stray commas, I do a search with the following pattern:

\,\s*(}|])

This saves heaps of time, especially since different browsers are more robust than others to misplaced commas.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文