views:

263

answers:

4

Trying to hit two elements with one load() and not successful in what I am trying. This is what I have now to refresh a section on the page and it works fine.

$('#refreshme_'+request).load("http://www.example.com/add_list/");

I tried this

$('#refreshme_'+request, .xPlanner).load("http://www.example.com/add_list/");

and that did not work at all. Want to make my code efficient and need to refresh 2 DOMs with one call. Any ideas?

+1  A: 
var request = "foo";
$("#refreshme_" + request + ", .xPlanner").load("http://www.example.com/add_list/");

and

<div id="#refreshme_foo">Lorem</div>
<div class="xPlanner">Ipsum</div>

works. Was this what you where trying to do?

svinto
+1  A: 

I wonder if you can't use something like:

$.get("http://www.example.com/add_list/", function(data) {
    $('#refreshme_'+request).html(data);
    // same for second
});
Marc Gravell
+1  A: 

You're going to want to use .get instead:

    $.get("http://www.example.com/add_list/", function(data) {
        $("#refreshme1").html(data);
        $("#refreshme2").html(data);
    });

That's pseudo, but you get the idea.

Peter J
A: 

Wow that is good stuff and all the examples work! One question is there performance increase by using .get over load()?

dvancouver