senchatouch jsonp不会在我的列表中加载数据
..
`Ext.define('App.store.AllProjects',{
extend:'Ext.data.Store',
config:{
autoLoad: true,
model:'App.model.AllProjects',
proxy:{
url:'http://server.com/allProjects.php',
type:'jsonp',
reader:{
rootProperty:'data',
type:'ajax'
}
}
}
});
`
这是我的数据..
{
data: [
{
"id": "1",
"name": "Leisureville",
"loc": "Kakkanad",
"project_image": "-F7qJ7GJ5ss_upload.gif"
},
{
"id": "2",
"name": "Green Hills",
"loc": "Kakkanad ",
"project_image": "-K2lmld7m6R_upload.gif"
},
{
"id": "3",
"name": "Laurel Grove",
"loc": "Vyttila",
"project_image": "-84N4NI7nHf_upload.gif"
},
{
"id": "4",
"name": "Serene Orchard",
"loc": "Panampilly Nagar ",
"project_image": "-8Clk75RV3F_upload.gif"
},
{
"id": "5",
"name": "Great Orchard",
"loc": "Panampilly Nagar",
"project_image": "-DK8oozF0Km_upload.gif"
},
{
"id": "6",
"name": "Dover Court",
"loc": "M G Road",
"project_image": "-4aIew80rw8_upload.gif"
},
{
"id": "7",
"name": "Plum Flower",
"loc": "Byepass, Vytilla ",
"project_image": "-67dpg59ZAt_upload.gif"
},
{
"id": "8",
"name": "Green Gables",
"loc": "Edapally",
"project_image": "-HMB3PKbm9C_upload.gif"
},
{
"id": "9",
"name": "Kings Brook",
"loc": "Maradu",
"project_image": "-W8486zZL7h_upload.gif"
},
{
"id": "10",
"name": "Promenades ",
"loc": "Palarivattom",
"project_image": "-sBQUbcy5pl_upload.gif"
},
{
"id": "11",
"name": "Silver Lawns",
"loc": "Edapally",
"project_image": "-QAMLFTtexZ_upload.gif"
},
{
"id": "12",
"name": "White Waters",
"loc": "Thevara",
"project_image": "-qJwO9MLYNq_upload.gif"
},
{
"id": "13",
"name": "Ivory Heights",
"loc": "Panampilly Nagar",
"project_image": "-4f3l5JG9Yo_upload.gif"
},
{
"id": "14",
"name": "Maison d'or",
"loc": "Panampilly Nagar",
"project_image": "-VmNOyUDuam_upload.gif"
},
{
"id": "15",
"name": "Berry Woods",
"loc": "chembumukku",
"project_image": "-3jR6o3D390_upload.jpg"
},
{
"id": "16",
"name": "Highlands",
"loc": "IT City",
"project_image": "-wmta9QJjcd_upload.gif"
},
{
"id": "17",
"name": "Esperanza",
"loc": "Seaport Airport Road, Kakkanad",
"project_image": "-T21A9E7Knu_upload.gif"
},
{
"id": "18",
"name": "Serenade",
"loc": "Palarivattom",
"project_image": "-23TAyDatBI_upload.jpg"
},
{
"id": "19",
"name": "El Castillo",
"loc": "Jawahar Nagar",
"project_image": "-tr6otl7MdZ_upload.gif"
},
{
"id": "20",
"name": "Hacienda ",
"loc": "Aluva",
"project_image": "-icnluy8N5B_upload.gif"
},
{
"id": "21",
"name": "Veneziano ",
"loc": "Koonamavu",
"project_image": "-9sQ6MbT3zX_upload.jpg"
}
]
}
和我用来获取它的PHP是
<?php
include("autoload.php");
$util = new Utils();
$records=$util->listAllProjects();
$result=json_encode($records);
echo "{data:".$result."}";
?>
我的错误是什么??
答案 0 :(得分:0)
使用JSON reader。
代理使用JSON Reader来读取服务器响应 以JSON格式发回。
更改
reader:{
type:'ajax',
.....
}
到
reader:{
type:'json',
.....
}
答案 1 :(得分:0)
我用过
echo 'Ext.util.JSONP.callback1('. json_encode($records) . ');
在我的php结束.. 并将我的商店改为以下..并且它有效..
Ext.define('Mather.store.AllProjects',{
extend:'Ext.data.Store',
config:{
autoLoad: true,
model:'Mather.model.AllProjects',
proxy:{
url:'http://server.com/allProjects.php',
type:'jsonp',
reader:{
rootProperty:'record',
type:'json'
},
callbackKey : 'callback'
}
}
});
感谢所有帮助过我的人..希望代码能帮助我一个人