2009-02-02 62 views
1

試圖用一個load()命中兩個元素,但在我所嘗試的中沒有成功。這是我現在刷新頁面上的一節,它工作正常。JQuery Effect多元素

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

我想這

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

,但這並沒有在所有的工作。希望使我的代碼高效並需要通過一次調用來刷新2個DOM。有任何想法嗎?

回答

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

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

作品。這是你在哪裏試圖做的?

1

我不知道,如果你不能使用類似:

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

你會想改用不用彷徨:

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

那是假的,但你的想法。