Get the App
SLTechnology News&Howtos  ›  Development  › 

How to upload Files asynchronously by Ajax

Shulou Source: shulou.com Published: 2022-06-03 20:17:04 11月12日 Update

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.

Tags: Articles files more good practical events code content data articles knowledge references help related Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple Shulou Technology NVidia MySQL macOS