[英]Javascript not referencing local json file
I cannot seem to be able to get my variable to reference the local json file instead of the current remote json file. 我似乎无法让我的变量引用本地json文件而不是当前的远程json文件。 I want to be able to set the Javascript to read the local test.json file instead of the remote resturl url.
我希望能够将Javascript设置为读取本地test.json文件,而不是远程resturl url。 I want to change the current resturl variable to the commented resturl below it.
我想将当前的resturl变量更改为其下方的注释过的resturl。 Please let me know if you need more information.
如果您需要更多信息,请告诉我。 The scripts are based off of: https://github.com/kenklin/aws-price-comparison-chart
脚本基于以下内容: https : //github.com/kenklin/aws-price-comparison-chart
function update() {
// Construct REST URL
var resturl = "http://p1software-eb1.elasticbeanstalk.com/awsec2offering/api"
+ "/" + d3.select("#availabilityZone").node().value // us-east-1a
+ "/" + d3.select("#productDescription").node().value // linux
+ "/" + d3.select("#offeringType").node().value // heavy
+ "/" + d3.select("#instanceType1").node().value // t1.micro
+ "," + d3.select("#instanceType2").node().value; // m1.small
// resturl = "test.json"
// resturl = "http://localhost:8080/awsec2offering/awsec2offering/api/us-east-1a/linux/heavy/t1.micro,m1.small."
d3.json(resturl, function(error, json) {
data = json.ec2offerings;
// Assign colors to each unique name.
var color = d3.scale.category10();
color.domain(data.map(function(p) { return createUniqueName(p); }));
// Coerce the data to numbers.
data.forEach(function(d) {
d.month = +d.month;
});
JSONP with callback parameter to get cross-domain scripting 带有回调参数的JSONP以获取跨域脚本
How to send data using JSONP from localhost to domain.com 如何使用JSONP将数据从本地主机发送到domain.com
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.