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

“你正在尝试解码一个无效的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

  • 写回答

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'
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器