views:

85

answers:

3

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.

+2  A: 

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.

SBUJOLD
What is strange is that I can take out the:"Message":"'.$tmp['Message'].'"in the PHP, and the grid will display the dates just fine. I'll have to check out that json_encode.
TBell
Well, the `Message` might contain a quote mark or other character that is special in JSON/JavaScript string literals. Failing to escape characters for their context is a big source of security holes, which is why you want to be using `json_encode` to create your output and definitely not string-slinging.
bobince
Would any thing below be considered a special character? It's just your basic dhcp log.I've gotten the problem knocked down to something in here not parsing correctly, because my code works and can store everything else in its rightful place...except this "Message" portion.Apr 9 00:00:02 dh1 dhcpd: DHCPACK on 10.193.X.X to 00:21:xx:53:xx:e1 (xxxxxx-PC) via 10.193.xx.xx Apr 9 00:00:02 dh1 dhcpd: Added new forward map from xx.wifi-uhs.xx to 10.193.xx.xx Apr 9 00:00:02 dh1 dhcpd: added reverse map from 242.244.xx.xx.in-addr.arpa. to xx.wifi-uhs.xx
TBell
A: 

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.

dave
A: 

Apr 9 00:00:02 dh1 dhcpd: DHCPACK on 10.193.X.X to 00:21:xx:53:xx:e1 (xxxxxx-PC) via 10.193.xx.xx

There are tabs between the date, dh1, and the actual log message itself. Can anyone help me figure out how to escape these? I think that may be my issue.

TBell