如何使用 jquery 从页面数组加载 - 按顺序 [英] how to use jquery to load from array of pages - in order

查看:21
本文介绍了如何使用 jquery 从页面数组加载 - 按顺序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从一个页面抓取一堆链接,然后从这些页面中提取特定的内容元素.我刚刚创建的代码可以正常工作.

问题是因为请求是异步的,元素没有按顺序加载.我尝试添加延迟,但没有奏效.

我需要使用 .ajax 而不是 .load 吗?如果是这样,使用 .ajax 命令时,这个循环追加会是什么样子?您仍然可以使用带有 url 的选择器吗?或者有没有一种有效的方法可以通过 .load 实现这一点?

提前致谢.

 函数 runthis() {var links = $("#article-slide-belt a").map(function() {返回 this.href;}).得到();$.each( 链接, 函数(i, l){$("

").load(l + " .gl_left", function() {$(".gl_left").append($(this).find(".gl_left").html());});});}

解决方案

也许是这样的:http://plugins.jquery.com/project/ajaxqueue

I'm grabbing a bunch of links from a page and then pulling in a specific content element from those pages. The code I just created works and does just that.

The problem is because the requests are asynchronous, the elements are not loading up in order. I tried adding a delay but that didn't work.

Do I need to be using .ajax instead of .load? If so, what would this looped append look like with .ajax command? Can you still use a selector with the url? Or is there an effective way to acheive this with .load?

Thanks in advance.

    function runthis() {

var links = $("#article-slide-belt a").map(function() {
                return this.href;
            }).get();

$.each( links, function(i, l){

    $("<div>").load(l + " .gl_left", function() {
          $(".gl_left").append($(this).find(".gl_left").html());
    });

 });

}

解决方案

Perhaps this: http://plugins.jquery.com/project/ajaxqueue

这篇关于如何使用 jquery 从页面数组加载 - 按顺序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆