加载失败 - 参数:[对象api =对象,对象请求=对象读取器=对象范围=对象,对象tId = 0状态= 200 statusText =确定,语法错误:丢失}属性列表消息=丢失后}属性列表]
我通过在我的商店中添加一个例外来解决这个错误,但是我的代码中没有看到任何真正的错误......也许另一组眼睛会有所帮助。
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(函数(){
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是相关的,因为它一切正常,但希望有人可以发现我的坏眼睛不能发现的东西。
答案 0 :(得分:2)
我在这里看到一个额外的逗号:
var searchButton = new Ext.Button({
text: 'Search',
});
同样在LogGrid上。那可能是它
编辑:如果出现错误data{"error_title"
错误,那么从PHP发回的响应看起来不是有效的JSON,应该是data:{"error_titel"
你真的应该看看在PHP中构建对象/数组并使用json_encode回应它们,而不是手动构建JSON。
答案 1 :(得分:0)
顺便说一句:要查找流浪逗号,我会使用以下模式进行搜索:
\,\ S *(} |])
这节省了大量时间,特别是因为不同的浏览器比其他浏览器更容易错位逗号。