如何显示使用jQuery load()来阿贾克斯多个项目分为多个元素呢?多个、元素、项目、jQuery

2023-09-10 14:40:00 作者:折扇公子

我需要加载从一个大页面的某些项目到页面中的不同元素。在code我写的是工作,但项目由一个和大量的停顿之后,装载之一。我想我可能会做错误的方式,因为我不是一个完整的开发者,但只是一个设计师。

I need to load certain items from a big page into a page's different elements. The code I wrote is working but items load one by one and after a lot of pause. I am thinking I might doing it wrong way as I am not a complete developer but just a designer.

我的code看喜欢:

$("#lot-rental").load("/est.html #est-rental");
$("#lot-deposit").load("/est.html #est-deposit");
$("#lot-date").load("/est.html #est-date");
$("#lot-build").load("/est.html #est-build");

请帮我它有点急了我。您的帮助将是AP preciated。谢谢

Please help me its kinda urgent for me. Your help will be appreciated. Thanks

推荐答案

使用 $。获得()加载数据,然后手动设置各种元素的含量

Use $.get() to load the data and then set the content of the various elements manually.

$.get('/est.html', function(data) {
    $.each(['rental', 'deposit', 'data', 'build'], function(i, key) {
        $('#lot-' + key).html($(data).find('#est-' + key));
    });
}, 'html');