KendoUI 和 json [英] KendoUI and json

查看:18
本文介绍了KendoUI 和 json的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对 kendoUI 和 json 很陌生,我的问题是数据似乎没有加载,可能是架构不正确或其他什么,没有错误,只是组合框一直在加载.这是我的示例代码:

I'm quite new to kendoUI and json, my problem is that It's seems the data does not load, maybe incorrect schema or something, get no errors, just the combobox loading the whole time. Here's my sample code:

$(document).ready(function () {
    clientDS = new kendo.data.DataSource({
        transport: {
            read: {
                url: "http://localhost/JSON_MP.asmx/GetListCountries?developerId=101&developerHash=9df7273b410761f74331bde746e5c2354b73b487&timestamp=1242207092430",  //Note the URL path!
                dataType: "json",
                contentType: "application/json; charset=utf-8"

            }
        },
        schema: {
            data: "listValues"               
        }
    });

    $("#kendoCboClient").kendoComboBox({
        placeholder: "Select a Country...",
        dataTextField: "name",
        dataValueField: "id",
        dataSource: clientDS
    });
});

和我的数据栈:

{"errorString":"ok","errorCode":0,"listValues":[{"name":"UNKNOWN","id":1},{"name":"南非","id":2},{"name":"Mozambique","id":3},{"name":"Philippines","id":4},{"name":"Namibia","id":5},{"name":"United Arab Emirates","id":6},{"name":"England","id":7},{"name":"Swaziland","id":8},{"name":"Portugal","id":9},{"name":"Greece","id":10},{"name":"Mauritius","id":11},{"name":"TANZANIA","id":12},{"name":"Botswana","id":13},{"name":"Spain","id":15},{"name":"Scottland","id":16},{"name":"Australia","id":17},{"name":"新西兰","id":18},{"name":"Cyprus","id":19},{"name":"United States","id":20},{"name":"Germany","id":21},{"name":"","id":22},{"name":"Madagascar","id":23},{"name":"Malaysia","id":24},{"name":"塞舌尔","id":25}],"listType":"国家"}

{"errorString":"ok","errorCode":0,"listValues":[{"name":"UNKNOWN","id":1},{"name":"South Africa","id":2},{"name":"Mozambique","id":3},{"name":"Philippines","id":4},{"name":"Namibia","id":5},{"name":"United Arab Emirates","id":6},{"name":"England","id":7},{"name":"Swaziland","id":8},{"name":"Portugal","id":9},{"name":"Greece","id":10},{"name":"Mauritius","id":11},{"name":"TANZANIA","id":12},{"name":"Botswana","id":13},{"name":"Spain","id":15},{"name":"Scottland","id":16},{"name":"Australia","id":17},{"name":"New Zealand","id":18},{"name":"Cyprus","id":19},{"name":"United States","id":20},{"name":"Germany","id":21},{"name":"","id":22},{"name":"Madagascar","id":23},{"name":"Malaysia","id":24},{"name":"Seychelles","id":25}],"listType":"Country"}

如果有人能指出我正确的方向或其他什么,请注意在数据堆栈中我使用的是listValues"对象,可能是因为"errorString":ok",errorCode":0," 那部分是什么问题?

If someone can just point me into the right direction or something, note that in the data-stack I'm using "listValues" objects, can be maybe because the ""errorString":"ok","errorCode":0," part that is the issue?

推荐答案

我遇到了类似的问题 - 没有数据也没有错误.实际问题是返回 json 数据的页面正在发送html"内容类型标头而不是application/json".这个问题实际上在这里解决:http://docs.kendoui.c​​om/tutorials/PHP/build-apps-with-kendo-ui-and-php(向下滚动到没有数据..."部分)并通过确保您正在发送正确的内容类型标头.

I had a similar issue - no data and no error. The actual problem was that the page returning the json data was sending "html" content type header instead of the "application/json". This issue is actually addressed here: http://docs.kendoui.com/tutorials/PHP/build-apps-with-kendo-ui-and-php (scroll half-way down to the section "There’s No Data…") and is fixed by making sure that you are sending the correct content type header.

这篇关于KendoUI 和 json的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆