我试图添加一个表格中的表单元素的Ajax/jQuery的。如果我在没有ajax的情况下设置它,一切正常,但不知何故,<form>
标签中的所有内容都完全丢失了。我不知道我在哪里失去了表单(jquery的.html()与innerHTML的效果是一样的吗?如果是这种情况,我怀疑这是我失去它的地方)。表格从AJAX响应中删除
总之,这里的一些代码:
var worow = document.getElementById('worow_' + row);
var wotable = document.getElementById('tbl_workorders');
// add a new row to the table underneath our existing row.
var newrow = wotable.insertRow(worow.rowIndex+1);
var x = newrow.insertCell(0);
// set up the row a little bit
x.colSpan = 13;
x.style.padding = '10px';
x.style.backgroundColor = '#ccc';
x.align = "center";
x.innerHTML = '<img src="/images/loading.gif" />';
// a little ajax cuz we're cool that way
$.post("getwotrans.php",
{
workorder: row
},
function(response)
{
// set the value of the row = response object from the AJAX
$(x).html(response);
});
而且在getwotrans.php:(意译)
<table>
<thead><tr><td>blahblah</td></tr></thead>
<tbody><form><tr><td><input></td></tr></form></tbody>
</table>
所以会发生什么是我要运行的JavaScript函数中添加的行,行被添加好了,我看到了表头,但tbody里的'form'不在那里。
这里有一些阅读给你。 http://www.w3.org/TR/html401/struct/tables.html – 2009-06-26 14:31:50
哦,请翻译一下表格,并快速描述我正在尝试做什么。它的实际结构并不重要。感谢您的狙击。 – 2009-06-30 04:22:38