jquery - cant pull deal from living social api, unexpected security token error -
my getting unexpected token error when trying pull deals living social api, code below:
$(window).load(function(){ var $result = $('#container') $.ajax({ type: 'get', url: 'http://monocle.livingsocial.com/v2/deals?api-key=8551a250feb245e5836cdb902c163a6c', datatype: 'jsonp', jsonp:"jsonp" }).done(function(data){ console.log(data) $.each(data.deals, function(idx, deal){ var html = '<div class="dealsmall masonry-brick"><div class="image"><div class="merchant">' + deal.id + '<img src="' + deal.description + '"/></div></div><div class="dealdetail"><div class="dealname">' + deal.image + '</div><div class="price">' + deal.options[0].price.formattedamount + '</div></div></div>' $result.append(html) }) }); });//]]>
check http://jsfiddle.net/mswl6/2/
you need set format 'jsonp'
var $result = $('#container') $.ajax({ type: 'get', url: 'http://monocle.livingsocial.com/v2/deals?api-key=8551a250feb245e5836cdb902c163a6c&format=jsonp', datatype: 'jsonp' }).done(function(data){ console.log(data) $.each(data.deals, function(idx, deal){ var html = '<div class="dealsmall masonry-brick"><div class="image"><div class="merchant">' + deal.id + '<img src="' + deal.description + '"/></div></div><div class="dealdetail"><div class="dealname">' + deal.image + '</div><div class="price">' + deal.options[0].price.formattedamount + '</div></div></div>' $result.append(html) }) });
Comments
Post a Comment