1

尝试从 live social api 中提取交易时出现意外令牌错误,代码如下:

$(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)
    })
});
});//]]>  
4

1 回答 1

2

检查这个 http://jsfiddle.net/mSWL6/2/

您需要将格式设置为“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)
    })
});
于 2013-08-16T02:54:39.047 回答