如何使用sencha Php

时间:2011-10-31 12:03:34

标签: sencha-touch jsonp extjs

我是Sencha的新人 我创造了

var genres = new Ext.data.Store({   autoLoad: true, 
            proxy: {
                url: '../www/App/stores/genres.php'
                ,callbackKey: "callback"
                , type:'ajax',
                 reader:{
                        type:'json',
                        root:'rows'
                 }, 
                 callback:function(data){
                 alert(data);}
            },
            fields:[{name:'ii',type: 'int'},{name:'genre_name',type:'string'   }]
            }); 

php文件创建json文件,但如果我创建json文件,我无法访问它们而不是它可以正常工作?帮助

1 个答案:

答案 0 :(得分:0)

你是否在php服务器上正确实现了回调?像这样:

$callback = $_REQUEST['callback'];

// Create the output object.
$output = array('a' => 'Apple', 'b' => 'Banana');

//start output
if ($callback) {
    header('Content-Type: text/javascript');
    echo $callback . '(' . json_encode($output) . ');';
} else {
    header('Content-Type: application/x-json');
    echo json_encode($output);
}