2012-07-06 26 views
0

我做了一個返回html表格的ajax請求。當我只是做一個位置重定向到該頁面時,表格顯示正確,但是當我將ajax響應放入div元素中時,表格變形。ajax請求返回的表格顯示不正確

function submitQuery() { 
    length = category_query.length; 
    if(category_query.indexOf('ALL') != -1) 
    category_query = category_query.substring(0,length-4);  
    xmlhttp.onreadystatechange=function() { 
    if(xmlhttp.readyState==4 && xmlhttp.status==200) 
     document.getElementById('resultDiv1').innerHTML = xmlhttp.responseText; 
    } 
    xmlhttp.open("GET","cons_query.php?q="+category_query,true); 
    xmlhttp.send(); 
    //window.location="cons_query.php?q="+category_query; 
    //if i just redirect to this location, the table is displayed fine. 
} 

我希望表格看起來像是通過ajax。

+1

使用jQuery更容易的AJAX請求。 – Hidde 2012-07-06 07:09:37

+0

確保表格獲得樣式 – 2012-07-06 07:09:39

+0

@COLDTOLD如何獲得其樣式? – user1505986 2012-07-06 07:18:01

回答

0

嗯......看起來你正在將行元素左側浮動到你的響應頁面中。 只需從css中刪除該格式 它應該看起來像這樣 td {width:<> px;向左飄浮; }