KendoUI:错误jQuery未被调用

时间:2013-02-04 17:09:13

标签: jquery kendo-ui

调用jsonp响应但收到错误:jQuery18207158344800118357_1359997121430未被调用。有人可以让我知道如何解决这个问题吗?感谢您的帮助。 以下是客户端代码:

var dataSource = new kendo.data.DataSource({
serverPaging: true,
                    pageSize: 2,
                    type: "odata",
                    error: function(e) {
                        console.log("Error " + e);
                        alert(e.errorThrown);
                    },
                    transport: {
                        read: {
                            url: "http://localhost:50675/movie/GetAll", // the remove service url
                            dataType: "jsonp"
                        },
                        parameterMap: function(options) {
                            alert("Inside parameterMap")
                            alert(JSON.stringify(options, null, 4));
                            return {
                                q: "javascript",
                                page: options.page,
                                rpp: options.pageSize,
                            };
                        }
                  },
                  schema: {
                         errors: function(response) {
                            return response.errors;
                        },
                        data: function(data) {
                             if (data.movieList.length == 0) {
                                return [];
                             }
                            return data.movieList;
                        },
                        total: function(data) {
                            alert(data.movieList.length);
                            return data.movieList.length;
                        }
                   }
            });

            $("#localListView").kendoMobileListView({
                dataSource: dataSource,
                pullToRefresh: true,
                appendOnRefresh: true,
                template: $("#categories-template").html(),
                pullParameters: function(item) {
                    alert("Inside pullParameters")
                    alert(item.length);
                    alert(JSON.stringify(item, null, 4));
                    return {
                        page: 1
                    };
                }
            });

在Chrome开发者工具中检查后,系统会成功收到服务器的响应。 以下是来自服务器的jsonp响应:

({ “movieList”:[{ “ID”:1, “标题”: “电影”, “RELEASEDATE”: “/日期(487189800000)/”, “流派”: “喜剧”, “价格”: 30},{ “ID”:1, “标题”: “电影”, “RELEASEDATE”: “/日期(487189800000)/”, “流派”: “喜剧”, “价格”:30}], “计数” :4})

1 个答案:

答案 0 :(得分:0)

在我看来,你的JSONP并不完整,我认为它应该是这样的:

jQuery18207158344800118357_1359997121430({"movieList":[{"ID":1,"Title":"Movie","ReleaseDate":"\/Date(487189800000)\/","Genre":"Comedy","Price":30},{"ID":1,"Title":"Movie","ReleaseDate":"\/Date(487189800000)\/","Genre":"Comedy","Price":30}],"count":4});

jQuery18207158344800118357_1359997121430在哪里是可变的,您将收到$callback请求参数。