JSONP inner workings with AJAX
This question already has an answer here:
It works exactly the way you thought it should:
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
下一篇: JSONP内部工作与AJAX