简体   繁体   中英

Combining Jquery Ajax calls for Instagram

Hello I programmed a site that accesses the Instagram API with Jquery. It's working fine, the only thing is that the client would like to have more than the 20 images. I've been looking everywhere but cannot find how to loop the ajax call so that it runs through all the available ajax queries with the url next information. For right now the code I have is

$.ajax({
        type: "GET",
        dataType: "jsonp",
        cache: false,
        url: "https://api.instagram.com/v1/users/*my user code* /media/recent/?access_token=* my access token*",
        success: function(data) {

My display code here
}

Is there a way to get all of the data from all of the calls and combine them into one data object so my code can loop through that?

Thank you very much.

You can kick off multiple AJAX requests and then wait for all of them to finish using $.when. Once $.when returns, it will have the data for all of your requests as parameters to its .done() callback. I've illustrated this in the jsfiddle here:

http://jsfiddle.net/dflor003/BeNdE/

Check out this link: http://thegregthompson.com/displaying-instagram-images-ignoring-page-pagination/

He explains how to do what you're looking for, good luck!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM