0

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."}";
?>

我的错误是什么..?

4

2 回答 2

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

感谢所有帮助过我的人.. 希望代码对 SME 有帮助

于 2012-05-30T16:34:28.983 回答
0

使用JSON 阅读器

代理使用 JSON Reader 读取以 JSON 格式发回的服务器响应。

改变

reader:{
    type:'ajax',
    .....            
}

reader:{
    type:'json',
    .....
}
于 2012-05-30T03:19:02.710 回答