Reputation: 232
I'm trying to pull info from this sample JSON file in their company API documentation. But it's not returning any results :(
$.getJSON("http://api.8coupons.com/v1/getcategory", function (data) {
$.each(data, function (index, item) {
$("<div>").html(item.category).appendTo("#content");
if (index == 3) {
return false;
}
});
});
Upvotes: 1
Views: 76
Reputation: 40639
Use a callback parameter
for different domain,
$.getJSON("http://api.8coupons.com/v1/getcategory?callback=?", function (data) {
$.each(data, function (index, item) {
$("<div>").html(item.category).appendTo("#content");
if (index == 3) {
return false;
}
});
});
Also read the same origin policy and JSON-to-JSONP-Bypass-Same-Origin-Policy
Upvotes: 2
Reputation: 95022
Add ?callback
to the url so that getJSON performs jsonp request rather than ajax/cors/json.
http://api.8coupons.com/v1/getcategory?callback=?
http://jsfiddle.net/Tentonaxe/28hEb/22/
Upvotes: 6