2014-09-01 79 views
0

好日子,“你试图解码的JSON字符串无效”,但它是一个PHP

我在ExtJS的5和MVVM相当新。我想创建一个ajax请求,以便显示一个带有用php捕获的数据的treepanel。

这里是我的商店

Ext.define('MyApp.store.servicesStore', { 
    extend: 'Ext.data.TreeStore', 
    // alias: 'store.servicesStore', 
    storeId : 'servicesStore', 
    model : 'MyApp.model.servicesModel', 
    proxy: { 
     type: 'ajax', 
     url: 'app/store/data/GetServices.php' 
    }, 
    root: { 
     text: 'Events', 
     id: 'root' 
    }, 
    autoLoad: true, 
    folderSort: true 
}); 

我已经看到了一个“成功”可以解决问题,但我并不需要一个更迭,因为它是在TreePanel中

Ext.define('MyApp.view.tabServices.servicesTab', {  
    extend: 'Ext.tree.Panel', 
    xtype: 'servicesTab', 
    layout: { 
     type: 'border' 
    }, 
    useArrows: true, 
    rootVisible: false, 
    store: {type: 'servicesStore'}, 
    forceFit: true, 
    columns: [{ 
     xtype: 'treecolumn', 
     dataIndex: 'text', 
     width: 600 
    }, { 
     dataIndex: 'mbt', 
     cls: 'mbtcss', 
     width: 80 
    }, { 
     dataIndex: 'bt', 
     cls: 'btcss', 
     width: 75 
    }, { 
     dataIndex: 'details', // port separated from rest 
     width: 60 
    }, { 
     dataIndex: 'code', 
     width: 80 
    }] 
}); 

只显示因此,当我启动我的应用程序时,出现了“您尝试解码无效的JSON字符串”,我该怎么做才能让它明白我实际上使用了一个PHP文件? 更准确地说,该代码在extjs 3.4中运行

+0

PHP脚本调用'json_decode()'吗? – Barmar 2014-09-01 14:21:46

+0

@Barmar不,我使用json_encode()。为了使它更清楚,我将jsut从extjs 3.4迁移到extjs 5.0,所以这是在extjs 3.4中工作的,我要精确的说我的问题 – So4ne 2014-09-01 14:35:31

+0

我想这个答案适用于你,但它本来是你更容易发布你的PHP生成的数据。 – Alexander 2014-09-02 07:44:06

回答

相关问题