0

動的データがリストに表示されません。データは jsonp 形式で動的に取得されます。Chrome 開発者ツールでチェックインすると、応答を確認できます。以下のコードを見つけてください。誰かがここで私を助けることができますか?

<!DOCTYPE html>
<html>
<head>
<title>Pull to refresh</title>
<script src="../../lib/jquery.min.js"></script>
<script src="../../lib/kendo.mobile.min.js"></script>
<link href="../../lib/styles/kendo.mobile.all.min.css" rel="stylesheet" />
<link href="../../lib/styles/kendo.common.min.css" rel="stylesheet" />

<div data-role="view" data-init="mobileListViewPullToRefresh" data-title="Pull to refresh">
    <header data-role="header">
        <div data-role="navbar">
            <span data-role="view-title"></span>
            <a data-align="right" data-role="button" class="nav-button" href="#index">Index</a>
        </div>
    </header>

    <ul id="pull-to-refresh-listview"></ul>
</div>

<script id="pull-to-refresh-template" type="text/x-kendo-template">
    #= Title #
</script>

<script>
function mobileListViewPullToRefresh() {
        var dataSource = new kendo.data.DataSource({
            serverPaging: true,
            pageSize: 1,
            transport: {
                read: {
                    url: "http://localhost/MvcMovieApp/Mobile/RestResponse", // the remove service url
                    dataType: "jsonp" // JSONP (JSON with padding) is required for cross-domain AJAX
                },
                parameterMap: function(options) {
                    alert(kendo.stringify(options));
                    return {
                        q: "javascript",
                        page: options.page,
                        rpp: options.pageSize
                        since_id: options.since_id //additional parameters sent to the remote service
                    };
                }
            },
            schema: { 
                data: "movies" // the data which the data source will be bound to is in the "results" field
            }
        });

    alert("Before kendoMobileListView");

    $("#pull-to-refresh-listview").kendoMobileListView({
        dataSource: dataSource ,
        pullToRefresh: function(){ alert("dataSource"); return true },
        appendOnRefresh: true,
        template: $("#pull-to-refresh-template").text(),
        endlessScroll: true,
        pullParameters: function(item) {
            return {
                since_id: item.id_str,
                page: 1
            };
        }
    });
}
</script>
<script>
 window.kendoMobileApplication = new kendo.mobile.Application(document.body);
</script>
</body>
</html>

私が受け取っている JSONP は次のとおりです: ({"movies":[{"ID":1,"Title":"Movie 1","ReleaseDate":"/Date(1355250600000)/","Genre":"Comedy" ,"価格":10},{"ID":2,"タイトル":"映画 2","リリース日":"/日付(1355250600000)/","ジャンル":"スリラー","価格":10 }]})

4

1 に答える 1

0

返された JSONP には、コールバック関数名が含まれている必要があります。ここに表示される出力には、関数名がありません。サーバー側のコードを変更する必要があります。

于 2013-06-30T08:14:41.437 に答える