jQuery将各种id加载到页面的各个部分

tbw*_*wcf 0 jquery load

在WordPress我已经成立了一个随机后拉页,使用jQuery我期待此刻的代码是低于本(随机)页当前(主页)上的各个部分的部分拉:

$('#wrongQuote').load('random/index.php #wrongSaying' + '?noCache=' + Math.floor(Math.random()*10001));
$('#sayingBy').load('random/index.php #author' + '?noCache=' + Math.floor(Math.random()*10001));
$('#actualQuote').load('random/index.php #actualSaying' + '?noCache=' + Math.floor(Math.random()*10001));

麻烦的是,这是拉动随机#wrongSaying,#author和#actualSaying ...我需要的是得到随机的,但配套#wrongSaying/#author/#actualSaying

所以我想我需要的是在该网页"随机/ index.php文件#wrongSaying"然后拿DIV#x和插入的div#A,DIV#楼为DIV#E等...

任何想法/帮助将不胜感激!

安迪

Nic*_*ver 7

我不会.load()在这里使用3个请求,我会自己加载并向服务器发出一个请求$.get(),如下所示:

$.get('random/index.php', { noCache: Math.floor(Math.random()*10001) }, 
  function(data) {
    data = $(data);
    $('#wrongQuote').html(data.find('#wrongSaying'));
    $('#sayingBy').html(data.find('#author'));
    $('#actualQuote').html(data.find('#actualSaying'));
});
Run Code Online (Sandbox Code Playgroud)

你得到的片段加载.load()是你自己无法做到的......当你重复相同的请求时,你不应该做自己的事情......高效并提出一个请求,IMO代码更可读.