douping3860
2014-09-01 14:17
浏览 127
已采纳

“你正在尝试解码一个无效的JSON字符串”但它是一个PHP

Good day,

I'm pretty new in extjs 5 and mvvm. I want to make an ajax request in order to display a treepanel with datas caught with a php.

Here is my store

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
});

I've seen that a "success" can resolve that issue but I don't need a succes as it's only displayed in a 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
    }]
});

So, when I launch my app, the "You're trying to decode an invalid JSON String" appears, how can I do to make it understand that I actually use a php file? More precisely, that code is working in extjs 3.4

图片转代码服务由CSDN问答提供 功能建议

美好的一天,

我是 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',
宽度:75 
},{
 dataIndex:'details',//端口与rest 
 width:60 
}分开,{
 dataIndex:' 代码',
宽度:80 
}] 
}); 
   
 
 

因此,当我启动我的应用程序时,“你正在尝试解码 出现了一个无效的JSON字符串,如何让它理解我实际使用的是php文件? 更确切地说,该代码在extjs 3.4中工作

  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • douningle7944 2014-09-01 15:05
    已采纳

    To run the PHP code which did work under ExtJS 4 you must either modify your PHP to return the data in JSON format. Or otherwise you set your "enable compatibility" to version 4.

    See "Enabling Compatibility" under http://docs.sencha.com/extjs/5.0/whats_new/5.0/extjs_upgrade_guide.html#Enabling_Compatibility.

    compatibility: {
        ext: '4.2'
    }
    
    已采纳该答案
    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题