2011-10-31 37 views
0

我新的煎茶 我创建如何与煎茶PHP一同工作

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文件,而不是它正常工作做什么,我不能访问它们?帮助

回答

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