2009-09-09 9 views
1

내 HTML이APPEND 데이터로드 문제

<div id="rsContainer"> 
     <table id="rsTable"><!-- DATA HERE --></table> 
</div> 

처럼 내 자바 스크립트는이 벌금과 작동이

$('#UpdateAll').click(function() { 

     $('#status').fadeIn('500').text('Loading... This may take a while.'); 
     $.ajax({ 
     type: 'post', 
     url: 'func.php', 
     data: 'action=updateAll', 

     success: function(response) { 
      $('#response').fadeOut('500').fadeIn('500').append(response); 

      $('#rsTable').slideUp('1000').load('index.php #rsTable', function() { 
       $(this).appendTo('#rsContainer').slideDown('1000'); 
      }); 

      $('#status').fadeOut('500').empty(); 
     } 
     });  
    }); 

비슷하지만, HTML을 appening하면이

<div id="rsContainer"> 
     <table id="rsTable"> 
      <table id="rsTable"><!--data--></table> 
     </table> 
</div> 
처럼 보인다 후

보시다시피 실제로 추가 할 수 있습니다. rsTable 어떻게 유지할 수 있습니까? 원래 구조?

감사합니다.

+0

그것을 추가하기 전에 응답의 값을 검사하려고합니다. 그것은 두 개의 rsTable 테이블을 포함하고 있습니까? –

답변

0
$('#rsContainer').slideUp('1000').load('index.php #rsTable', function() { 
    $(this).slideDown('1000'); 
}); 

슬라이드 ID를 상위 ID로 변경하십시오.

1

실행 한 테스트에서 .prepend() 전에 .emtpy()를 수행하면 .html()을 수행하는 것보다 200 회 이상 빠릅니다. 이상하지만 사실.

두 개의 rsTable을 모두 포함하려는 경우 ids가 고유해야하므로 rsTable을 카운터에 추가하거나 클래스를 사용해야합니다.

이 생각하고 싶은 것 같습니다 :

$('#rsContainer').empty(); 
$('#rsContainer').prepend($('#rsTable'));