$.ajax({
type: "POST",
url: "add_secondary_interest.php",
data: "interest=ok",
cache: false,
success: function(html){
$('#interest_table tr:last').after(html);
}
});
ajax响应是这样的
<select name="test[]">
<option value='7'>abc</option>
<option value='1'>xyz</option>
</select>
但是当我发布表单时,这个动态选择框没有发布。
最佳答案
简短的回答是,当 jQuery 添加元素时,它会绑定(bind)到表元素而不是表单元素。要解决此问题,请使 DOM 相对于表单。例如:
$.ajax({
type: "POST",
url: "add_secondary_interest.php",
data: "interest=ok",
cache: false,
success: function(html){
$('form #interest_table tr:last').after(html); //<<<<<
}}
关于php - 动态添加的选择框未发布,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10607358/