【发布时间】:2017-10-26 15:15:24
【问题描述】:
我正在使用 Amcharts 创建可旋转并变成水平条形图的柱形图。我正在使用 Amcharts 的 dataLoader 插件连接到连接到 mysql 并检索数据的 php 文件,并且 php 文件将数据输出为 JSON
我面临的问题是,如果 php 文件与包含 html 的文件位于同一文件夹中,则图表会正确加载
,
"dataLoader": {
"url": "data.php"
},
但如果我将 php 文件放在包含文件夹中,图表不会加载,并且会出现空白屏幕。
,
"dataLoader": {
"url": "http://MyWebsite.com/include/data.php"
},
我检查了根目录和包含文件夹中的 php json 文件,两者都正确输出了有效的 JSON
我不想使用 Jquery,而且我是 javascript 新手。请告诉我做错了什么。
更新 -
此加载错误时断时续。这是浏览器控制台中出现的错误 - Failed to load http://MyWebsite.com/include/data.php: No 'Access-Control-Allow-Origin' header is present on the requested resource.Origin 'http://www.MyWebsite.com is therefore not allowed access
【问题讨论】:
-
您的浏览器控制台有错误吗?
-
没有。但我会尝试检查 1-2 天是否有任何错误
-
Failed to load http://MyWebsite.com/include/data.php: No 'Access-Control-Allow-Origin' header is present on the requested resource.Origin 'http://www.MyWebsite.com is therefore not allowed access@xorspark 这是我在浏览器控制台中遇到的错误。 -
也许你应该尝试
"/include/data.php"避开网址。 -
查看此链接:stackoverflow.com/questions/1653308/…。当您访问不同的地址时,您会遇到此问题。
标签: javascript php json amcharts