fpc-syq
$(\'form\').submit(function (event) {
      event.preventDefault();
      var form = $(this);

      if (!form.hasClass(\'fupload\')) {
        //普通表单
        $.ajax({
          type: form.attr(\'method\'),
          url: form.attr(\'action\'),
          data: form.serialize()
        }).success(function () {
          //成功提交
        }).fail(function (jqXHR, textStatus, errorThrown) {
          //错误信息
        });
      }
      else {
        // mulitipart form,如文件上传类
        var formData = new FormData(this);
        $.ajax({
          type: form.attr(\'method\'),
          url: form.attr(\'action\'),
          data: formData,
          mimeType: "multipart/form-data",
          contentType: false,
          cache: false,
          processData: false
        }).success(function () {
          //成功提交
        }).fail(function (jqXHR, textStatus, errorThrown) {
          //错误信息
        });
      };
    });

 

分类:

技术点:

相关文章:

  • 2021-12-27
  • 2021-12-27
  • 2022-12-23
  • 2021-12-27
  • 2021-12-27
  • 2021-12-27
  • 2022-12-23
  • 2021-12-26
猜你喜欢
  • 2021-12-27
  • 2021-12-27
  • 2021-07-04
  • 2022-12-23
  • 2022-02-07
  • 2021-12-27
  • 2021-12-27
相关资源
相似解决方案