Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2008/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Kendo ui KendoUI数据源导致JSON原语无效_Kendo Ui_Icenium - Fatal编程技术网

Kendo ui KendoUI数据源导致JSON原语无效

Kendo ui KendoUI数据源导致JSON原语无效,kendo-ui,icenium,Kendo Ui,Icenium,所以我已经用了一天左右的时间拼命地想让它发挥作用。如果这是简单和愚蠢的-对不起,谢谢。这是一篇相当长的文章,因为我试图描述我迄今为止所做的一切 所以我有一个ASMXWeb服务,我想用它来填充KendoUIListView。在我将数据添加到传输请求之前,这是非常有效的。因此,我的web服务现在看起来是这样的: WebMethod(Description = "Return All Pending Actions Based")] [ScriptMethod(ResponseFormat = Res

所以我已经用了一天左右的时间拼命地想让它发挥作用。如果这是简单和愚蠢的-对不起,谢谢。这是一篇相当长的文章,因为我试图描述我迄今为止所做的一切

所以我有一个ASMXWeb服务,我想用它来填充KendoUIListView。在我将数据添加到传输请求之前,这是非常有效的。因此,我的web服务现在看起来是这样的:

WebMethod(Description = "Return All Pending Actions Based")]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public PendingActionResult GetPendingActions(string sUsername, string sPassword, string sUserID, string sClubID)
{
   //code is here;
}
我的完整数据源如下所示:

dataSource = new kendo.data.DataSource({
                transport: {
                    read: {
                        type: "POST",
                        data:  "{'sUsername':'admin@mail.com','sPassword':'13123','sUserID':'1539','sClubID':'1'}",
                        url: "http://sdk.domain.com/services/general.asmx/GetPendingActions",
                        contentType: "application/json; charset=utf-8",
                        dataType: "json"
                    }
                },
                schema: {
                        data: "d.Data", // ASMX services return JSON in the following format { "d": <result> }. Specify how to get the result.
                        total: "d.Total",
                        model: {
                            id: "activityID",
                            fields: {
                                activityID: { type: "number", validation: {min: 1, required: true } },
                                taskName: { type: "string" },
                                taskNote: { type: "string" },
                                openDate: { type: "datetime" },
                                dueDate: { type: "datetime" },
                                priority: { type: "number" },
                                statusID: { type: "number" },
                                openedByID: { type: "number" },
                                assignedToID: { type: "number" },
                                statusName: { type: "string" },
                                complete: { type: "bool" }
                            }
                        }
                    }
            });

            that.set("pendingActionsDataSource", dataSource);
var jsPost = $.toJSON({
                sUsername: "admin@mail.com",
                sPassword: "13123",
                sUserID: "1539",
                sClubID: "1"
            });
(我会在网上发布这张照片,这样更容易看到)

所以在这里我可以清楚地看到字符串没有以正确的格式发送。所以我决定尝试一下,不使用Kendo数据源,而是使用JSON/AJAX。所以我打了这个:

function getPAs() {
    $.ajax({
    type: "POST",
    url: "http://sdk.domain.com/services/general.asmx/GetPendingActions",
    data:  "{'sUsername':'admin@mail.com','sPassword':'13123','sUserID':'1539','sClubID':'1'}",
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    success: getPAs_Success,
    error: app.onError
    });
}

function getPAs_Success(data, status) {
    console.log("START getPAs_Success");

    var cars = data.d;
    var sout = document.getElementById('nav');
    var output = "";
    $.each(cars, function(index, car) {
    output += '<p><strong>' + car.taskName + ' ' +
                            car.taskNote + '</strong><br /> Priority: ' +
                            car.priority + '<br />Status: ' +
                            car.statusID + '<br />Opened By: ' +
                            car.openedByID + '<br />Assigned To' +
                            car.assignedToID + '</p>';
    });
    sout.innerHTML = output;
    console.log("END getPAs_Success");
}
我在fiddler中也清楚地看到了我的JSON结果

所以我的问题是在所有这些之后:

为了实现这一点,我需要对剑道UI数据源做一些特殊的事情吗?如果有必要的话,我正在使用Icenium,并试图构建一个快速的移动应用程序来娱乐

谢谢

理查德

更新#1 两个都试过了,再也没有了

数据:{“sUsername”:admin@mail.com,“sPassword”:“13123”,“sUserID”:“1539”,“sClubID”:“1”}

它使用jsonlint.com进行验证,但当我现在查看fiddler时,我看到它被发送到服务器:

0=%7B&1='&2=s&3=U&4=s&5=e&6=r&7=n&8=a&9=m&10=e&11='&12=%3A&13='&14=a&15=d&16=m&17=i&18=n&19=%40&20=m&21=a&22=i&23=l&24=.&25=c&26=o&27=m&28='&29=%2C&30='&31=s&32=P&33=a&34=s&35=s&36=w&37=o&38=r&39=d&40='&41=%3A&42='&43=1&44=3&45=1&46=2&47=3&48='&49=%2C&50='&51=s&52=U&53=s&54=e&55=r&56=I&57=D&58='&59=%3A&60='&61=1&62=5&63=3&64=9&65='&66=%2C&67='&68=s&69=C&70=l&71=u&72=b&73=I&74=D&75='&76=%3A&77='&78=1&79='&80=%7D
{'sUsername':'admin@mail.com','sPassword':'13123','sUserID':'1539','sClubID':'1'}
sUsername=admin%40mail.com&sPassword=13123&sUserID=1539&sClubID=1

所以可能是因为我现在没有数据的引号,所以我尝试了以下方法:

var jsPost = {
                sUsername: "admin@mail.com",
                sPassword: "13123",
                sUserID: "1539",
                sClubID: "1"
            };
数据:“{”sUsername:”admin@mail.com“,“sPassword”:“13123”,“sUserID”:“1539”,“sClubID”:“1”}”

当我这样做的时候,我会得到同样的0=%7的混乱。。。如上所述

当我尝试使用toJSON时,我得到一个对象函数没有方法。这样做:

dataSource = new kendo.data.DataSource({
                transport: {
                    read: {
                        type: "POST",
                        data:  "{'sUsername':'admin@mail.com','sPassword':'13123','sUserID':'1539','sClubID':'1'}",
                        url: "http://sdk.domain.com/services/general.asmx/GetPendingActions",
                        contentType: "application/json; charset=utf-8",
                        dataType: "json"
                    }
                },
                schema: {
                        data: "d.Data", // ASMX services return JSON in the following format { "d": <result> }. Specify how to get the result.
                        total: "d.Total",
                        model: {
                            id: "activityID",
                            fields: {
                                activityID: { type: "number", validation: {min: 1, required: true } },
                                taskName: { type: "string" },
                                taskNote: { type: "string" },
                                openDate: { type: "datetime" },
                                dueDate: { type: "datetime" },
                                priority: { type: "number" },
                                statusID: { type: "number" },
                                openedByID: { type: "number" },
                                assignedToID: { type: "number" },
                                statusName: { type: "string" },
                                complete: { type: "bool" }
                            }
                        }
                    }
            });

            that.set("pendingActionsDataSource", dataSource);
var jsPost = $.toJSON({
                sUsername: "admin@mail.com",
                sPassword: "13123",
                sUserID: "1539",
                sClubID: "1"
            });
在telerik论坛上发现有人说不要使用toJSON,而是使用JSON.stringify,所以我尝试了以下方法:

var jsPost = {
                sUsername: "admin@mail.com",
                sPassword: "13123",
                sUserID: "1539",
                sClubID: "1"
            };


但是仍然会产生疯狂的垃圾。

一个有效的JSON格式需要双引号,而不是单引号。您可以尝试在服务中验证字符串,如。更好的是,您可以在对象上使用,而不是手动构建它。

您在这里或从Telerik获得过不包括嵌套$.ajax调用的答案吗?我也在讨论同样的问题。顺便说一句,谢谢你的解决方案。