我使用 d3.js 和 CodeIgniter,当我在运行此代码时使用 d3.json 获取 json 数据时遇到问题:
var url = "http://probe.dev/draw/windRose?station=vp2&sensors=wind&Since=2012-10-15T00:00:00&StepUnit=DAY&StepNbr=6;
d3.json(url, function(d) {
console.log(d); // print NULL in console
}
但它适用于
$.getJSON(url, function(d) {
console.log(d); // print my data object correctly
}
我的 php 代码是:
<?php
@ob_end_clean();
header('Content-Type: "application/json"');
header('Content-Disposition: attachment; filename="data.json"');
header("Content-Transfer-Encoding: binary");
header('Expires: 0');
header('Pragma: no-cache');
header("Content-Length: ".strlen($data));
exit($data);
我不明白为什么 d3.json 不起作用?