【问题标题】:Prevent html form submit while uploading file in jQuery-File-Upload plugin在 jQuery-File-Upload 插件中上传文件时防止 html 表单提交
【发布时间】:2014-12-17 12:16:12
【问题描述】:

我有一个html表单,作为表单的第二个元素,我正在上传带有jQuery-File-Upload 的文件,然后在它下面有一些html元素。在 html 表单的末尾有一个提交按钮。当我单击“浏览文件”按钮并选择要上传的文件时,所有 html 表单都在单击提交按钮时提交。这种情况会导致问题,因为“浏览文件”按钮下方有一些 html 表单元素,它们是空的。这是我的代码:

$(function () {
    'use strict';
    var url = 'control.php?upload_file';
    $('#file_upload').fileupload({
        url: url,
        dataType: 'text',
        done: function (e, data) {
            $("#result").html(data.result);
        },
        progressall: function (e, data) {
            $('#dosya_durum').show();
        }
    });
});

我没有解决这个问题。你可以帮帮我吗?

【问题讨论】:

  • 能否请您也发布您的 HTML 代码?
  • 禁用提交按钮,直到文件未上传。上传文件时删除禁用属性:)
  • 我也有同样的问题。你能解决它吗?

标签: jquery forms jquery-file-upload


【解决方案1】:

在导致问题的表格中,您不能使用onsubmit="return false;"

【讨论】:

  • 另外,根据我对您问题的理解,您在另一个表单中有一个表单,我认为这不是有效的 html 做法
  • 不,我只有一个 html 表单。文件上传时,表单同时提交。
  • 由于声誉不足,我无法在帖子下方发表评论,但感谢您的建议。
猜你喜欢
  • 2014-05-17
  • 1970-01-01
  • 2015-04-02
  • 1970-01-01
  • 1970-01-01
  • 2014-10-16
  • 1970-01-01
  • 1970-01-01
  • 2013-10-13
相关资源
最近更新 更多