繁体   English   中英

使用$ .getJSON在pagebeforeshow中获取json数据在jquery mobile中不起作用

[英]Using $.getJSON for getting json data in pagebeforeshow is not working in jquery mobile

我已经使用$ .getJSON在pagebeforeshow上获取json数据,但是它不能正常工作。

$(document).on('pagebeforeshow', '#inpGrid', function(e) {
        alert("inpGrid");
        var tat_url = "http://192.168./html5/Demo/json/list.json";

              var url = "http://api.openweathermap.org/data/2.5/forecast?lat=35&lon=139&callback=?" ;
              $.getJSON(tat_url, function(res) {
                  console.log(res)

});

    });

代码如上,当在$ .getJSON中使用url时,它起作用;而在使用tat_url时,则不起作用。

http://192.168./html5/Demo/json/list.json包含以下内容

{
    "response": {
        "respCode": 0,
        "output": {
            "delAction": "OP",
            "delTmplt": "sibcVizEdit",
            "title": "List TATs",
            "layout": "grid",
            "srvObjRef": "iawme1/IAWMblztnExpert-ListSIBCs_MB1412577249595",
            "startIndex": "0",
            "recsPerPage": "18",
            "noPages": "1",
            "curPageNo": "1",
            "fieldInfo": [
                {
                    "label": "Name",
                    "type": "STRING"
                }
                {
                    "label": "Alias",
                    "type": "STRING"
                }
                {
              "label": "Datatype",
               "type": "STRING"
                }
                {
            "label": "Default Value",
            "type": "STRING"
                }
                {
             "label": "Visibility",
            "type": "STRING"
                }
            ],
            "records": [
                {
                    "Name": "psngrType"
                    "Alias": "Pasngr Type"
                    "Datatype": "STRING"
                    "Default Value":"CC"
                    "Visibility": "0"
                },
                {
                    "Name": "flightNo"
            "Alias": "Flight No"
            "Datatype": "STRING"
            "Default Value":"$RV_flightNo"
                    "Visibility": "0"
                }
            ],
            "relServices": {
                "AServices": [
                    {
                        "ref": "IAWMblztnExpert-ListSIBCs-UpdateBizContext_MB",
                        "title": "Update SIBC",
                        "desc": "",
                        "srvRef": "IAWMblztnExpert-ListSIBCs-UpdateBizContext_MB",
                        "slctdOffsets": "0"
                    },
                    {
                        "ref": "IAWMblztnExpert-ListSIBCs-ListIICsInSIBC_MB",
                        "title": "List IICs",
                        "desc": "",
                        "srvRef": "IAWMblztnExpert-ListSIBCs-ListIICsInSIBC_MB",
                        "slctdOffsets": "0"
                    },
                    {
                        "ref": "IAWMblztnExpert-ListSIBCs-Deploy SIBC_MB",
                        "title": "Deploy",
                        "desc": "",
                        "srvRef": "IAWMblztnExpert-ListSIBCs-Deploy SIBC_MB",
                        "slctdOffsets": "0"
                    }
                ]
            }
        }
    }
}

有人可以帮我吗,谢谢。

您的JSON包含语法错误,请查看您的“ fieldInfo”节点。 您没有用来分隔不同的对象,

例:

            {
                "label": "Name",
                "type": "STRING"
            },
            {
                "label": "Alias",
                "type": "STRING"
            }

代替

            {
                "label": "Name",
                "type": "STRING"
            }
            {
                "label": "Alias",
                "type": "STRING"
            }

如果您需要轻松检查其余json文件,请使用在线JSON验证程序: http : //jsonlint.com/

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM