How to upload Files asynchronously by Ajax
This article will explain in detail how Ajax can upload files asynchronously. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.
The specific code is as follows:
Index$ (function () {$(': button') .click (function () {var formData = new FormData (); var file = $("input [type = 'file']") [0] .files [0]; formData.append ("files", file) $.ajax ({url:'/ Upload/Upload', / / server script to process datatype: 'POST',//Ajax event / / beforeSend: beforeSendHandler,//success: completeHandler,//error: errorHandler,// Form data data: formData,//Options to tell JQuery not to process data or worry about content-typecache: false,contentType: false,processData: false}) This is the end of the article on "how to upload files asynchronously by Ajax". I hope the above content can be helpful to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.