1

我在使用 .load () jquery 安装表时遇到问题。

我的表如下。

<table id="table_test">
     <thead>
        <tr>
          <th> COLUNA 1 </th>
        </tr>
     </thead>


    <tbody>

    </tbody>
</table>

我的文件组合了以下输出。

<tr>
 <td>
  <span> Value 2</span>
 </td>
</tr>

我正在使用以下功能。

<script type="text/javascript">
$(document).ready (function () {
         $('# table_test'). load ('modules/a/processa.php? opt = 2');
});
</ script>

但是它无法挂载表中的行。

http://jsfiddle.net/marcoscarraro/7NsNu/

有什么建议么?

4

2 回答 2

0

我认为您的问题在于$

这应该工作$('#table_test').load('modules/a/processa.php?opt=2');

于 2013-02-26T23:10:35.723 回答
0

您的问题中有很多拼写错误/语法错误。你可以在下面试试这个。我不确定您的数据返回什么,但我希望它确实可以正确返回文本。让我知道这个是否奏效。

HTML结构:

<table id="table_test">
  <thead>
    <tr>
      <th> COLUNA 1 </th>
    </tr>
   </thead>
   <tbody>
   </tbody>
</table>

JS代码:

$(document).ready(function () {
    $('#table_test tbody').load("modules/a/processa.php?opt=2", 
                                function(response, status, xhr) {
     if (status == "error") {
         var msg = "Sorry but there was an error: ";
         alert(msg + xhr.status + " " + xhr.statusText);
     }
  });
});

JS 小提琴:http: //jsfiddle.net/QztST/3/

于 2013-02-26T23:21:08.233 回答