d3.json请求成功,但收到错误消息

时间:2018-10-02 06:29:53

标签: javascript d3.js

我正在尝试使用d3.js。

它已发送请求,请求成功。

enter image description here enter image description here

但是我收到一条错误消息

enter image description here

有人可以告诉我如何解决吗?

非常感谢您!

我的代码如下

var Condt = {
"Condition": {
    "Column": [
        {
            "Name": "Date",
            "Type": "datetime",
            "Value": [
                { "Min": "2018-01-01" },
                { "Max": "2018-09-01" + " 23:59:59" }
            ]
        }
    ]
}
};
   
var CondtJson = JSON.stringify(Condt)
var url = "https://cchk3.kingwi.org/AppService/Analysis.asmx/GetStatisticsTotalVolumeForPC?PageSize=10000&PageCount=1&ConditionJson=" + CondtJson;
console.log('url', url);
d3.json(url).then((data)=>{console.log(data);})
<script src="https://d3js.org/d3.v5.min.js"></script>

1 个答案:

答案 0 :(得分:1)

就像@altocumulus一样,您收到的响应似乎不是有效的JSON,因为它以括号开头。查看URL本身,似乎您的整个JSON都包裹在(" ")

将来,如果您想自己捕获此错误,可以对诺言使用.catch语句。有关示例,请参见d3 changelog