动态添加的表单字段未显示在POST数据中

问题描述:

我正在使用jQuery添加表单元素.它会正确显示在页面上,并具有正确的值,但是当我提交表单时,数据不会显示在PHP后端上.我查看了Firebug的POST数据,也没有在其中看到.我用来添加表单元素的javascript是:

I'm using jQuery to add a form element. It appears on the page fine, with the correct value, but when I submit the form, the data doesn't show up on the PHP backend. I looked at Firebug's POST data and I don't see it in there either. The javascript I'm using to add the form element is:

$("#projectArray").append("<input type='text' name='data[Project][description]' value='"+projectDescription+"' id='test' />");

有人遇到过这样的事情吗?我似乎还有其他帖子,但它们似乎是错别字,据我所知,这一行没有任何错字.

Has anyone run across anything like this? I've seem other posts but they seem to be typos and from what I can tell, I don't have any typos in this line.

编辑:根据要求,这里是表格代码.我把它剪掉了很多,因为它是一个很大的形式.如果有人想要完整的代码,我可以将其粘贴.

Edit: As requested, here is the form code. I cut a lot of it out, as it is a pretty large form. If anyone wants the complete code, I can paste it.

<form action="/learningexperiences/add" id="LearningexperienceAddForm" method="post" accept-charset="utf-8">
    <div style="display:none;"><input type="hidden" name="_method" value="POST"/></div>
    <div class="input text"><tr><td><label for="LearningexperienceSubjectarea">Subject Area</label>&nbsp;&nbsp;</td><td><input name="data[Learningexperience][subjectarea]" maxlength="50" type="text" id="LearningexperienceSubjectarea"/></td></tr>
...
    <tr><td>Active</td><td><div class="cbx"><input type="hidden" name="data[Learningexperience][active]" id="LearningexperienceActive_" value="0"/><input type="checkbox" name="data[Learningexperience][active]"  checked="checked" value="1" id="LearningexperienceActive"/></div></td></tr>

    <tr><td colspan="2" style="vertical-align:middle;"><div id="projectArray"></div></td></tr>

...
    <input type="hidden" name="data[Learningexperience][id]" id="LearningexperienceId"/><tr><td colspan="2" style="vertical-align:middle;">&nbsp;</td></tr>

</table>

<table id="buttonsTable">
<tr><td style="text-align:right;"><div style="margin-right:5px;"><div class="submit"><input  name="cancel" type="submit" value="Cancel"/></div></div></td>
<td><div class="submit"><input  type="submit" value="Save Record"/></div></form></td></tr>
</table>

我更改了append标签以附加到表单元素(#LearningexperienceAddForm).我不知道为什么,但是它从那时开始起作用.

Edit 2: I changed my append tag to append to the form element (#LearningexperienceAddForm). I don't know why, but it started working at that point.

我更改了我的append标签,以附加到表单元素(#LearningexperienceAddForm).我不知道为什么,但是它从那时开始起作用.

I changed my append tag to append to the form element (#LearningexperienceAddForm). I don't know why, but it started working at that point.