在jQuery中克隆或向表单添加输入不会在Firefox中提交给PHP [英] Cloning or adding an input to a form in jQuery does not submit to PHP in Firefox
问题描述
$('#images_upload_add').click(function(){
$('.images_upload:last').after($('.images_upload:last').clone().find('input[type=file]').val('').end());
});
使用此代码附加文件输入不会在firefox中上传文件。
using this code to append file input's does not upload the file in firefox.
还
$('#image_server_add input[type=button]').click(function(){
var select = $(this).siblings('select').find(':selected');
if(select.val()){
$('#image_server_add').before('<tr class="images_selection"><td><input type="button" value="Delete"></td><td class="main">'+select.html()+'<input type="hidden" value="'+select.html()+'" name="images_server[]"/></td></tr>');
}
})
也不上传$ _POST的价值
also does not upload the values to the $_POST
我找不到任何说法为什么这在文档中不起作用,这适用于IE但不适用于Firefox / WebKit
I can't find anything to say why this wouldn't work in the documentation, this works in IE but not it Firefox/WebKit
为什么这些例子不能正确上传表格值?
Why wouldn't these examples correctly upload the form values?
推荐答案
底线页面上的标记被破坏了。
Bottom line the markup on the page was mangled.
表单是基于表格的布局,而不是我的选择,表格声明在tr中。
The form was in a table based layout, not by my choice, and the form declaration was inside a tr.
我将表单声明移动到表单输入的父td,现在它可以工作。
I moved the form declaration to a parent td of the form inputs and now it works.
这是一个有趣的结果,考虑到渲染引擎将正确提交不正确放置的输入,但尝试使用jQuery / javascript添加这些输入?进入同一个地方将无法在Firefox / WebKit中工作。
This is an interesting result considering the rendering engine will correctly submit inputs that are improperly placed, but attempting to add those inputs using jQuery/javascript? into the same place will not work in Firefox/WebKit.
我想这与javascript所做的dom操作以及它对块的更严格有关等级元素要求。
I imagine this has to do with the dom manipulation that javascript does and how it may be more strict about the block level element requirements.
有关我的调查结果的更多注释/猜想将不胜感激。
Any more notes/conjectures about my findings would be appreciated.
这篇关于在jQuery中克隆或向表单添加输入不会在Firefox中提交给PHP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!