Reputation: 2968
I can't seem to get jquery to return anything from the groupon API.
When I check in apigee I can do a simple get request to get all divisions.
But when I try in JSFiddle it ain't working
$.get('https://api.groupon.com/v2/divisions.json?client_id=b91d375e38147f3c1e0339a3588d0b791c190424', function(data) {
console.log(data);
});
The $.get above returns a response that's empty.
$.getJSON("https://api.groupon.com/v2/divisions.json?client_id=b91d375e38147f3c1e0339a3588d0b791c190424&jsoncallback=?", function(json) {
console.log(data);
});
This one returns an error
invalid label
[Break On This Error] {"divisions":[{"id":"abbotsford","name...owCustomerEnabled":false,"areas":[]}]}
What am I doing wrong here?
Here is the JSFIDDLE :
Upvotes: 2
Views: 949
Reputation: 82634
You will need JSONP because it will be cross domain:
$.ajax({
url: 'https://api.groupon.com/v2/divisions.json?client_id=b91d375e38147f3c1e0339a3588d0b791c190424',
dataType: 'jsonp',
success: function(data) {
$('#result').html(data);
alert(data.divisions);
}});
Upvotes: 1