繁体   English   中英

Javascript不引用本地json文件

[英]Javascript not referencing local json file

我似乎无法让我的变量引用本地json文件而不是当前的远程json文件。 我希望能够将Javascript设置为读取本地test.json文件,而不是远程resturl url。 我想将当前的resturl变量更改为其下方的注释过的resturl。 如果您需要更多信息,请告诉我。 脚本基于以下内容: 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以获取跨域脚本

如何使用JSONP将数据从本地主机发送到domain.com

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM