【问题标题】:problem getting a json multi dimensional array to work with jquery getJSON让 json 多维数组与 jquery getJSON 一起使用的问题
【发布时间】:2011-04-02 11:27:43
【问题描述】:

我正在使用 jquery.getJson() 来检索由我的 php 脚本创建的 json 对象。

如果我删除位置数组,它会起作用。但是我需要位置数组来填充组合框。

我的格式化 json 如下。任何建议我如何让它与一个 json 查询而不是 2 一起工作。

{ "ContactID" : "1", "CustomerID" : "1", "FirstName" : "john", "LastName" : "smith", "Position" : "General Manager", "ContactNumber" : "234523455", "FaxNumber" : "235235234", "LocationSelected" : "1", "Default" : "default", locations : {0 : { "addressID" : "1" , "description" : "Street Address" }}}

我也试过这样

{ "ContactID" : "1", "CustomerID" : "1", "FirstName" : "john", "LastName" : "smith", "Position" : "General Manager", "ContactNumber" : "234523455", "FaxNumber" : "235235234", "LocationSelected" : "1", "Default" : "default", locations : [{ "addressID" : "1" , "description" : "Street Address" }]}

【问题讨论】:

    标签: jquery json getjson


    【解决方案1】:

    它应该像那样工作。只需确保您使用的是正确的 mime 类型即可。

    change mime type of output in php

    What is the correct JSON content type?

    也许您还应该使用引用位置键

    ... "locations" : [{ "addressID" : "1" , "description" : "Street Address" }]}
    

    您还可以使用 PHP 的 JSON 函数来生成 JSON。 http://fi2.php.net/manual/en/book.json.php

    【讨论】:

      【解决方案2】:

      这可能会解决您的问题.. Json retrivethis one too

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-08-02
        • 2016-03-23
        • 2014-03-06
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多