JSONP inner workings with AJAX

This question already has an answer here:

  • What is JSONP all about? [duplicate] 7 answers

  • It works exactly the way you thought it should:

    JSONP通过XHR

    It adds an async script tag into head , and immediately removes it after calling the callback function.


    Update

    Only to inform, I was using the JSONP flickr API in the example above:

    setTimeout(function() {
      $.getJSON('http://api.flickr.com/services/feeds/photos_public.gne?jsoncallback=?', {
          tags: 'jquery',
          tagmode: 'any',
          format: 'json'
        },
        function(data) {
          $.each(data.items, function(i, item) {
            $('<img />').attr('src', item.media.m).appendTo('#images');
          });
        });
    }, 2000);
    
    链接地址: http://www.djcxy.com/p/8352.html

    上一篇: 如何从Java中的不同类读取私有字段的值?

    下一篇: JSONP内部工作与AJAX