I'm trying to turn the value at the key of "1" of this cross-domain JSON into a js array on my site.
I tried using $.getJSON()
, but I encountered a cross-domain origin error. I tried AJAX and got a cross-domain origin error.
Is there any way I can get around this and user the JSON?
Here is my attempt using $.getJSON()
:
var trends = '';
var json = 'http://hawttrends.appspot.com/api/terms/';
$.getJSON(json, function(trends){
console.log(trends["1"]);
});
Here is my AJAX attempt:
$.ajax({
type:'GET',
dataType:'jsonp',
data:{},
url:'http://hawttrends.appspot.com/api/terms/',
error:function(jqXHR, textStatus, errorThrown){
console.log(jqXHR);
},
success:function(msg){
if (msg) {
var myArray = [];
$.each(msg, function(i, item) {
//do whatever you want for each row in json
myArray.push(item);
});
}
}
});
If the only way to do this is on a server. How can I parse the JSON and turn the values of the key "1" to elements in a CSV file in Go ( Golang ).