Problems reading JSON file in D3 javascript in some (not all) browsers(在某些(不是全部)浏览器中读取 D3 javascript 中的 JSON 文件时出现问题)
问题描述
我在读取 JSON 文件后立即在 Chrome 中收到此错误.它可以在 Safari 和 Firefox 中正常运行.
I get this error in Chrome immediately after reading a JSON file. It works correctly in Safari and Firefox.
console.log ("事件 -> "+ postcards.nodes[0].node.event);//Safari 中的 "tally" "TypeError: Cannot read property 'node' of undefined" 在 Chrome 中.<
console.log ("event -> "+ postcards.nodes[0].node.event); // "tally" in Safari "TypeError: Cannot read property 'node' of undefined" in Chrome.<
嵌套 JSON 文件中的级别是否有限制?我从 Drupal 视图生成 JSON.这里是开始:
Is there a limit to the levels in a nested JSON file? I generate the JSON from a Drupal view. Here here is the start:
{"nodes":[{"node":{"w1":"","w2":"1","w3":"","w4":"", ...<
这里是 Javascript:
Here is the Javascript:
d3.json(
"/sites/default/d3_files/json/toronto-wards.json",
function(error,wards) {
d3.json("/postcards-json", function(error, postcards) {
console.log ("event -> "+ postcards.nodes[0].node.event); // tally in Safari
我正在使用 macOS,而我的朋友使用 Windows 在 Firefox 中遇到了同样的错误.
I'm using macOS and my friends using Windows get the same error in Firefox.
根据要求,我认为这是 XHR 消息:
As per request here is what I think is the XHR message:
d3.min.js:1 XHR finished loading: GET "http://www.stopplastics.ca/postcards-json".
推荐答案
问题是由于 Drupal 视图没有正确创建造成的.与 Chrome 浏览器无关.
The problem was caused by the Drupal view not being created correctly. Nothing to do with the Chrome browser.
这篇关于在某些(不是全部)浏览器中读取 D3 javascript 中的 JSON 文件时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在某些(不是全部)浏览器中读取 D3 javascript 中的 JSON 文件时出现问题


- 在不使用循环的情况下查找数字数组中的一项 2022-01-01
- 是否可以将标志传递给 Gulp 以使其以不同的方式 2022-01-01
- 如何向 ipc 渲染器发送添加回调 2022-01-01
- 使用 iframe URL 的 jQuery UI 对话框 2022-01-01
- 我不能使用 json 使用 react 向我的 web api 发出 Post 请求 2022-01-01
- 为什么我的页面无法在 Github 上加载? 2022-01-01
- 为什么悬停在委托事件处理程序中不起作用? 2022-01-01
- 如何显示带有换行符的文本标签? 2022-01-01
- 从原点悬停时触发 translateY() 2022-01-01
- 如何调试 CSS/Javascript 悬停问题 2022-01-01