Changing getJSON to JSONP

前端 未结 1 1395
逝去的感伤
逝去的感伤 2020-11-30 08:11

I have this code:




        
相关标签:
1条回答
  • 2020-11-30 08:41

    Actually, you just have to add ?callback=?, jQuery does the rest.

    $(document).ready(function() {
        $.getJSON('http://example.com/api/get_cats?callback=?', function(fbResults) {
            document.write(fbResults.cats[0].title);
        });
    });
    
    0 讨论(0)
提交回复
热议问题