0

I have the following json data like this:

var myjson = [{"orders":[
             {"id":16,"status":"completed","total":"45.00"},
             {"id":17,"status":"completed","total":"55.00"}
             ]}];

But I need to be able to get the json data from a remote source with a url like this:

https://example.com/wc-api/v1/orders?consumer_key=ABC&consumer_secret=123

In browser will display the exact same JSON data as above, but how can I use it in my javascript?

There are similar answered questions out there, but none of the solutions seemed to work. Please make it understandable for a beginner with little javascript/jQuery experience, thank you! :)

EDIT:

I tried this solution:

var page_content;
$.get( "https://example.com/wc-api/v1/orders?consumer_key=ABC&consumer_secret=123", function(data){
    page_content = data;
});

I get this error in the console:

XMLHttpRequest cannot load https://example.com/wc-api/v1/orders?consumer_key=ABC&consumer_secret=123. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access.

Please help :(

Alberto
  • 23
  • 4
  • 1
    "There are similar answered questions out there, but none of the solutions seemed to work" — We can't tell why they didn't work for you if you don't show us what you tried (and what the results of debugging it using the Console and Network tab in your browser's developer tools were). – Quentin Jul 01 '16 at 15:01
  • @Quentin I edited the post! Please help, thank you – Alberto Jul 01 '16 at 16:26
  • @AlbertoPebble — Now you have a very search engine friendly error message you could type into Google. Here is a duplicate: http://stackoverflow.com/questions/35553500/ – Quentin Jul 01 '16 at 17:52

0 Answers0