间隔在阿贾克斯

I'm using soap to fetch some data, using a function that's made by the destination web site, but the problem is that with the function i'm allowed to fetch 50 datum per request.

I intend to use ajax for this, for instance i've 170 id and wanna get information about them. in every request i can fetch 50 of them. wanna know if there is a way to make a break or pause with ajax and then request the second 50 or not ?

or anything that can be used in my case.

thanks in advance ;)

There's a wonderful function called setTimeout() in Javascript which will execute some code after a certain amount of time. If you need it to repeat several times, you can use setInterval() instead.

For setTimeout(): http://www.w3schools.com/jsref/met_win_settimeout.asp

For setInterval(): http://www.w3schools.com/jsref/met_win_setinterval.asp

Hm... What you CAN do is to fetch 50 elements in your Ajax function, and execute the Ajax call again in the Ajax return callback.

An example with jQuery would look like this:

var fetch = 170;
var responses = [];

function getStuff(offset) {
    offset = offset || 0;
    if (offset >= 170) return false;
    $.get({
        url: 'mybackend.php',
        params: {offset: offset, limit: 50},
        success: function(ret) {
            if (offset < fetch)
                getStuff(offset + 50)
            responses.put(ret);
        }
    });
}

// Start:
getStuff();

This will start Ajax call one after another, until the 170 elements are fetched. In the end, you got all the responses in the responses array.