jQuery catch img

Posted by Happy on Stack Overflow See other posts from Stack Overflow or by Happy
Published on 2010-06-16T15:37:48Z Indexed on 2010/06/16 17:42 UTC
Read the original article Hit count: 128

Filed under:

We have a script used for each .item:

$(".item").each(function(){
    item_link = "http://...";
    block = $('.block', this);
    $.get(item_link, function(data) {
        var src = $('img.slide', data).attr('src');
        block.html(src);
    });
});

item_link variable is uniquie for each query.

There can be 100 .item or more.

The problem is - server has limit on connections at the same time, that why some .item get var src, some not.

The best solution is to use just one .get at the same time. I think there should be some counter, if .get is finished - it gives message "I'm finished, you can start" to the next .get and so on.

How to do that?

Thanks.

© Stack Overflow or respective owner

Related posts about jQuery