JQuery ajaxForm:如果在 beforeSubmit 中从 DOM 中删除表单,则不会提交表单
如果我在 beforeSubmit 或 beforeSend 中从 DOM 中删除表单(无论哪一个),我发现在 IE 和 FF 中,永远不会发出 http 请求。调用 jquery.form.js 中的 form.submit() 第 296 行,但没有发出 http 请求。但它在 chrome 中工作正常。
示例代码:
$('#form1').ajaxForm(
{
beforeSubmit: function(array, matched_set, options)
{
// this line removes #form1 from the DOM.
// it is still available to jquery form plugin by means of closure
// line 296 form.submit() in jquery.form.js is hit,
// but IE and FF never emit http request. If I remove this line, it works.
$('#jqm_window').html(waiting_page);
},
铬: 火狐浏览器: 使用 chrome 时,fiddler 会捕获 http 跟踪(但不会使用其他浏览器):
if I remove the form from the DOM in beforeSubmit or beforeSend (doesn't matter which one), I find that in both IE and FF, http request is never emitted. form.submit() line 296 in jquery.form.js is called, but no http request is emitted. It works correctly in chrome though.
Sample code:
$('#form1').ajaxForm(
{
beforeSubmit: function(array, matched_set, options)
{
// this line removes #form1 from the DOM.
// it is still available to jquery form plugin by means of closure
// line 296 form.submit() in jquery.form.js is hit,
// but IE and FF never emit http request. If I remove this line, it works.
$('#jqm_window').html(waiting_page);
},
chrome:
firefox:
http trace is captured in fiddler when using chrome (but not with other browsers):
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这不是 jquery 问题。如果在提交之前将表单从 DOM 中删除,则 IE、FF 不会提交表单。完整代码:
this is not a jquery issue. IE, FF don't submit form if its removed from DOM prior to submitting. Full code:
我有同样的问题。我创建 jQuery 表单对象并调用提交函数,该函数在 Chrome 中工作正常,但在 Firefox 中不行。
Chrome 和 Firefox 有不同的 js 引擎,在 Firefox 中你不能提交不在 DOM 中的表单元素。
I have the same issue. I create jQuery form object and call submit function which works fine in Chrome but not in Firefox.
Chrome and Firefox have different js engines and in Firefox you cannot submit form element which is not in DOM.