无法解析json数组开始于[

时间:2017-03-21 04:33:22

标签: jquery arrays json

我有一个json数组:

[{
"id": "xx",
"type": "xx",
"description": {
"type": "string",
"value": "xxx",
"metadata": {}
},
"imageurl": {
"type": "string",
"value": "xxx",
"metadata": {}
},
"location": {
"type": "string",
"value": "xxx",
"metadata": {}
}
}]

我想通过带有头请求的Ajax解析它:

 $.ajax({
                type: "GET",
                url: "http://192.168.xxx.xx", 
                dataType: "jsonp",
                contentType:"application/json",
                cache: true,
                headers: { "fiware-service": "smartcity" , "fiware-servicepath": "/"},
                error:function(e){
                            console.log(e);
                            alert("noooooo");
                },
                success: function (data) {
                         alert("yesssss");
    //for(var a=0;a<25;a++){


    //}

         }
   });

但我总是得到noooo,并没有成功获得json数组,为什么? dataType有什么问题吗?任何人都可以帮忙吗?

非常感谢

2 个答案:

答案 0 :(得分:0)

您可以尝试JSON.parse(input_data)

参考:jQuery loop over JSON string

答案 1 :(得分:0)

最后,我使用代理来解决这个问题。谢谢大家。