0

I cannot seem to be able to get my variable to reference the local json file instead of the current remote json file. I want to be able to set the Javascript to read the local test.json file instead of the remote resturl url. I want to change the current resturl variable to the commented resturl below it. Please let me know if you need more information. The scripts are based off of: 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;
  });
user3757992
  • 159
  • 7

1 Answers1

0

JSONP with callback parameter to get cross-domain scripting

How to send data using JSONP from localhost to domain.com

Community
  • 1
  • 1
Stephen
  • 71
  • 3
  • I'm unsure of what to do there. I have no experience with JSONP. Could you possibly provide a code-based answer? – user3757992 Jun 24 '14 at 19:07
  • Assuming that your code is running off a server, example.com, and you want localhost, then your localhost url should be: `http://localhost:8080/test.json?callback=?` This might also work, but unlikely: `file:///path/to/file/test.json?callback=?` – Stephen Jun 24 '14 at 19:17
  • I'm not sure how I'd write that because http://localhost:8080/test.json did not seem to work. It's in the same directory. – user3757992 Jun 24 '14 at 19:20
  • Sorry, I had to edit my answer because I keep hitting `enter` on accident. – Stephen Jun 24 '14 at 19:21
  • Here is another reference URL: http://stackoverflow.com/questions/5943630/basic-example-of-using-ajax-with-jsonp – Stephen Jun 24 '14 at 19:23
  • It's just running locally on my machine for now. Any ideas for running it off of your own machine? What's the last callback=? for too? – user3757992 Jun 24 '14 at 19:23