jQuery load various id's into sections of the page -


in wordpress have page set pull in random post, using jquery i'm looking pull in sections of (random) page various sections on current (home) page @ moment code below:

$('#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));

the trouble pulling in random #wrongsaying, #author , #actualsaying... need random, matching #wrongsaying / #author / #actualsaying

so guess need page 'random/index.php #wrongsaying' take div#x , insert div#a, div#f div#e , on...

any ideas / appreciated!

andy

i wouldn't use .load() 3 requests here, i'd loading , make one request server using $.get(), this:

$.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')); }); 

the fragment loading .load() nothing can't yourself...and when you're repeating same request it's shouldn't yourself...be efficient , make 1 request, more readable code imo.


Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

aspxgridview - Devexpress grid - header filter does not work if column is initially hidden -

c# - How to execute a particular part of code asynchronously in a class -