Home > Web Front-end > JS Tutorial > body text

AjaxSubmit() submits the file file

亚连
Release: 2018-05-22 16:48:43
Original
2657 people have browsed it

This article mainly introduces the example explanation of AjaxSubmit() to submit file files. It is very good and has reference value. Friends who need it can refer to it.

I have checked various methods on the Internet before, and I want to Submit the file file and be able to receive the return value. It is recommended to use the ajaxSubmit() method.

Most of the recommendations on the Internet are like this:

$("#formId").submit(
  $(this).ajaxSubmit({
    url:...,
    type:...,
    success:function(){
    ...
    }
  });
  return false;//阻止自动提交
);
Copy after login

But when you use it, you will find that there will be multiple submissions. Request once for the first time, twice for the second time….
And ajaxSubmit() itself has the submit() function, so there is no need to do this, just use:

var opt = {
  type:'post',            
  datatype:'json',
  url:'../../../rybmanagement/upLoadFile',            
  success: function(data) {
  ...
  }
};
$("#formId").ajaxSubmit(opt);//相当于from.submit()
Copy after login

Introduce the file:

<script src="jquery-form.js" type="text/javascript"></script>
<script src="../../js/jquery-2.1.1.min.js"></script>
Copy after login

The above is what I compiled for everyone. I hope it will be helpful to everyone in the future.

Related articles:

AjaxFileUpload Struts2 implements multi-file upload function

##Implements ajax sending asynchronous requests (graphic tutorial)

Ajax implementation of uploading images, saving them to the background and reading them (graphic tutorial)

The above is the detailed content of AjaxSubmit() submits the file file. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!