-2

以下の文字列をAndroidソースからjavascriptコールバックに送信したいと思います。

{
    "DefaultScope.mytable": {
        "name": "DefaultScope.mytable",
        "rows": {
            "http://www.xxx.com/demo/MyService/DefaultScopeSyncService.svc/mytable(ID=guid'69cb1eed-6ea4-c29d-ea7a-a3b4b8cde5bf')": {
                "ID": "69cb1eed-6ea4-c29d-ea7a-a3b4b8cde5bf",
                "FirstName": "xxx",
                "LastName": "x1x1",
                "PhoneNumber": "999922223",
                "EmailId": "xxxx@gmail.com",
                "__metadata": {
                    "uri": "http://www.xxx.com/demo/MyService/DefaultScopeSyncService.svc/mytable(ID=guid'69cb1eed-6ea4-c29d-ea7a-a3b4b8cde5bf')",
                    "type": "DefaultScope.mytable"
                }
            },
            "http://www.xxx.com/demo/MyService/DefaultScopeSyncService.svc/mytable(ID=guid'86159fca-1832-418a-0416-bb1e7555dd56')": {
                "ID": "86159fca-1832-418a-0416-bb1e7555dd56",
                "FirstName": "yyy",
                "LastName": "R",
                "PhoneNumber": "98789878",
                "EmailId": "yyyy@syncfusion.com",
                "__metadata": {
                    "uri": "http://www.xxx.com/demo/MyService/DefaultScopeSyncService.svc/mytable(ID=guid'86159fca-1832-418a-0416-bb1e7555dd56')",
                    "type": "DefaultScope.mytable"
                }
            },
            "http://www.xxx.com/demo/MyService/DefaultScopeSyncService.svc/mytable(ID=guid'000047f6-c01b-8e95-6a13-c44c75ec4537')": {
                "ID": "000047f6-c01b-8e95-6a13-c44c75ec4537",
                "FirstName": "Sample",
                "LastName": "Sample",
                "PhoneNumber": "999999999",
                "EmailId": "sample@syncfusion.com",
                "__metadata": {
                    "uri": "http://www.xxx.com/demo/MyService/DefaultScopeSyncService.svc/mytable(ID=guid'000047f6-c01b-8e95-6a13-c44c75ec4537')",
                    "type": "DefaultScope.mytable"
                }
            },
            "http://www.xxx.com/demo/MyService/DefaultScopeSyncService.svc/mytable(ID=guid'71d7b329-edd5-00dd-4579-eacfc6ebd129')": {
                "ID": "71d7b329-edd5-00dd-4579-eacfc6ebd129",
                "FirstName": "zzz",
                "LastName": "M",
                "PhoneNumber": "8787676733",
                "EmailId": "zzzz@syncfusion.com",
                "__metadata": {
                    "uri": "http://www.xxx.com/demo/MyService/DefaultScopeSyncService.svc/mytable(ID=guid'71d7b329-edd5-00dd-4579-eacfc6ebd129')",
                    "type": "DefaultScope.mytable"
                }
            },
            "http://www.xxx.com/demo/MyService/DefaultScopeSyncService.svc/mytable(ID=guid'b6e23d7c-5f06-7c25-f0c7-f7a67ae874db')": {
                "ID": "b6e23d7c-5f06-7c25-f0c7-f7a67ae874db",
                "FirstName": "dddd",
                "LastName": "r",
                "PhoneNumber": "8009008767",
                "EmailId": "dddd@syncfison.com",
                "__metadata": {
                    "uri": "http://www.xxx.com/demo/MyService/DefaultScopeSyncService.svc/mytable(ID=guid'b6e23d7c-5f06-7c25-f0c7-f7a67ae874db')",
                    "type": "DefaultScope.mytable"
                }
            },
            "d3be059d-14d7-7f5a-e7ab-7cf9d4d08fcf": {
                "__metadata": {
                    "type": "DefaultScope.mytable",
                    "tempId": "d3be059d-14d7-7f5a-e7ab-7cf9d4d08fcf",
                    "isDirty": true
                },
                "ID": "d3be059d-14d7-7f5a-e7ab-7cf9d4d08fcf",
                "FirstName": "bbb",
                "LastName": "aaa",
                "PhoneNumber": "9009877899",
                "EmailId": "abab@syncfusion.com"
            }
        }
    }
}

私はこれを以下のように私のJavaファイルにロードしました

webView.loadUrl("javascript:"+callBackName+"('" + mStatus + "', '" + mString+ "')");

折り返し電話:

var processor = (function () {
        return {
            onSuccess: function (data) {
                 alert("Success");
            },
            onFailure: function (error) {
                 alert("Error");
            }
        };
    })();

このコールバックは呼び出されません。

mString変数に「 hi」を渡すと、 onSuccessが呼び出されます。

4

1 に答える 1

0

上記の値に間違いがありました。文字列の単一引用符が多いため、Webviewに値をロードできません。これで、「\」を「\」に置き換えて文字列を作成しました。今は元気に働いています。

{
    "DefaultScope.mytable": {
        "name": "DefaultScope.mytable",
        "rows": {
            "http://www.xxx.com/demo/MyService/DefaultScopeSyncService.svc/mytable(ID=guid\’69cb1eed-6ea4-c29d-ea7a-a3b4b8cde5bf\’)": {
                "ID": "69cb1eed-6ea4-c29d-ea7a-a3b4b8cde5bf",
                "FirstName": "xxx",
                "LastName": "x1x1",
                "PhoneNumber": "999922223",
                "EmailId": "xxxx@gmail.com",
                "__metadata": {
                    "uri": "http://www.xxx.com/demo/MyService/DefaultScopeSyncService.svc/mytable(ID=guid\’69cb1eed-6ea4-c29d-ea7a-a3b4b8cde5bf\’)",
                    "type": "DefaultScope.mytable"
                }
            },
            "http://www.xxx.com/demo/MyService/DefaultScopeSyncService.svc/mytable(ID=guid\’86159fca-1832-418a-0416-bb1e7555dd56\’)": {
                "ID": "86159fca-1832-418a-0416-bb1e7555dd56",
                "FirstName": "yyy",
                "LastName": "R",
                "PhoneNumber": "98789878",
                "EmailId": "yyyy@syncfusion.com",
                "__metadata": {
                    "uri": "http://www.xxx.com/demo/MyService/DefaultScopeSyncService.svc/mytable(ID=guid\’86159fca-1832-418a-0416-bb1e7555dd56\’)",
                    "type": "DefaultScope.mytable"
                }
            },
            "http://www.xxx.com/demo/MyService/DefaultScopeSyncService.svc/mytable(ID=guid\’000047f6-c01b-8e95-6a13-c44c75ec4537\’)": {
                "ID": "000047f6-c01b-8e95-6a13-c44c75ec4537",
                "FirstName": "Sample",
                "LastName": "Sample",
                "PhoneNumber": "999999999",
                "EmailId": "sample@syncfusion.com",
                "__metadata": {
                    "uri": "http://www.xxx.com/demo/MyService/DefaultScopeSyncService.svc/mytable(ID=guid\’000047f6-c01b-8e95-6a13-c44c75ec4537\’)",
                    "type": "DefaultScope.mytable"
                }
            },
            "http://www.xxx.com/demo/MyService/DefaultScopeSyncService.svc/mytable(ID=guid\’71d7b329-edd5-00dd-4579-eacfc6ebd129\’)": {
                "ID": "71d7b329-edd5-00dd-4579-eacfc6ebd129",
                "FirstName": "zzz",
                "LastName": "M",
                "PhoneNumber": "8787676733",
                "EmailId": "zzzz@syncfusion.com",
                "__metadata": {
                    "uri": "http://www.xxx.com/demo/MyService/DefaultScopeSyncService.svc/mytable(ID=guid\’71d7b329-edd5-00dd-4579-eacfc6ebd129\’)",
                    "type": "DefaultScope.mytable"
                }
            },
            "http://www.xxx.com/demo/MyService/DefaultScopeSyncService.svc/mytable(ID=guid\’b6e23d7c-5f06-7c25-f0c7-f7a67ae874db\’)": {
                "ID": "b6e23d7c-5f06-7c25-f0c7-f7a67ae874db",
                "FirstName": "dddd",
                "LastName": "r",
                "PhoneNumber": "8009008767",
                "EmailId": "dddd@syncfison.com",
                "__metadata": {
                    "uri": "http://www.xxx.com/demo/MyService/DefaultScopeSyncService.svc/mytable(ID=guid\’b6e23d7c-5f06-7c25-f0c7-f7a67ae874db\’)",
                    "type": "DefaultScope.mytable"
                }
            },
            "d3be059d-14d7-7f5a-e7ab-7cf9d4d08fcf": {
                "__metadata": {
                    "type": "DefaultScope.mytable",
                    "tempId": "d3be059d-14d7-7f5a-e7ab-7cf9d4d08fcf",
                    "isDirty": true
                },
                "ID": "d3be059d-14d7-7f5a-e7ab-7cf9d4d08fcf",
                "FirstName": "bbb",
                "LastName": "aaa",
                "PhoneNumber": "9009877899",
                "EmailId": "abab@syncfusion.com"
            }
        }
    }
}
于 2013-02-08T04:41:13.813 に答える