1

Web サービスからデータを読み取る JSON ストアがあります。Web サービスからの JSON は有効です (ファイルから直接データを読み取ろうとしたところ、機能していました)。

JSON データは次のとおりです。

{
"type": "FeatureCollection",
"name": "Points",
"keyField": "GPSUserName",
"features": [
    {
        "type": "Feature",
        "geometry": {
            "type": "Point",
            "coordinates": [
                35.19999,
                31.780965
            ]
        },
        "properties": {
            "GPSId": "<img src=images/battery3.png />",
            "DateTime": "12/07/2013 09:05:00",
            "GPSUserName": "13",
            "GPSUserColor": "#00FF57",
            "GPSUserIcon": "marker_red2.png",
            "GPSLabelPosX": "6",
            "GPSLabelPosY": "7"
        }
    },
    {
        "type": "Feature",
        "geometry": {
            "type": "Point",
            "coordinates": [
                35.201142,
                31.780699
            ]
        },
        "properties": {
            "GPSId": "<img src=images/battery4.png />",
            "DateTime": "12/07/2013 09:05:00",
            "GPSUserName": "14",
            "GPSUserColor": "#00FF57",
            "GPSUserIcon": "marker_red2.png",
            "GPSLabelPosX": "6",
            "GPSLabelPosY": "7"
        }
    }
]

}

次のストアを使用すると、すべてが正常に機能します。

 initComponent: function () {

    this.store = new Ext.data.JsonStore({
        storeId: 'usersStore',
        autoLoad: true,
        autoSync: false,
        proxy: {
            type: 'ajax',
            url: 'data/users.json',
            reader: {
                type: 'json',
                root: 'features'
            }
        },
        fields: [
            { name: 'name', mapping: 'properties.GPSUserName'},
            { name: 'date', mapping: 'properties.DateTime' },
            { name: 'battery', mapping: 'properties.GPSId' }
        ]
    });

    this.columns = [
        { header: 'name', dataIndex: 'name', flex: 1 },
        { header: 'date', dataIndex: 'date', flex: 3 },
        { header: 'battery', dataIndex: 'battery', flex: 1 }
    ];

    this.callParent(arguments);
}

しかし、(ファイルの内容を返す) Web サービスを使用するように変更すると、何も機能しません:

 initComponent: function () {

    this.store = new Ext.data.JsonStore({
        storeId: 'usersStore',
        autoLoad: true,
        autoSync: false,
        proxy: new Ext.data.HttpProxy({
            url: 'service.asmx/GetJson',
            headers: { 'Content-Type': 'application/json; charset=utf-8;' },
            reader: { root: 'd', record: 'features' }
        }),  

        fields: [
            { name: 'name', mapping: 'properties.GPSUserName'},
            { name: 'date', mapping: 'properties.DateTime' },
            { name: 'battery', mapping: 'properties.GPSId' }
        ]
    });                  

    this.callParent(arguments);
}

そしてこれはウェブサービスです:

[WebMethod]
    [ScriptMethod(ResponseFormat = ResponseFormat.Json, UseHttpGet = true, XmlSerializeString = false)]
    public string GetJson()
    {
        string res = File.ReadAllText("data\users.json");
        return res;
        /*HttpContext.Current.Response.Clear();
        HttpContext.Current.Response.ContentType = "application/json";
        HttpContext.Current.Response.Charset = "utf-8";
        HttpContext.Current.Response.Write(res);*/
    }

firebug では、呼び出しから次の戻り値が表示されます。 ここに画像の説明を入力

だから...私はここで何が欠けていますか?

4

1 に答える 1