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 :(