How to upload files asynchronously in html
This time I will show you how to upload files asynchronously in HTML. What are the precautions for uploading files asynchronously in HTML? Here is a practical case, let’s take a look.
The code is as follows:<form action="/hehe" method="post"> <input type="text" value="hehe"/> <input type="submit" value="upload" id="upload"/> </form>
First introduce a solution to save the country through curves. The above code snippets do not need to be changed. Just add the following code
<iframe id="uploadFrame" name="uploadFrame"></iframe>
attribute in the form, target=uploadFrame, target The attribute needs to be consistent with the value of the id in the iframe (or the value of the name attribute, you will know after you try it).
A brief explanation, in fact, our form here is refreshed after submission, but why is there no jump to the page? It is because of this iframe. In fact, we refreshed it in the iframe, and the iframe is empty, that is It is the same as not refreshing, giving us an asynchronous feeling. This is not an orthodox method, but it is also a way to save the country. Of course, this method is not applicable in many cases. For example, we want to submit a completed form. After retrieving something from the server, this method obviously won't work. Here we also need to truly asynchronously submit the table.
(2)
jqueryAsynchronous submission of form
Here is introduced ajaxupload, a form submission plug-in for jquery, and its usage is relatively simple
<body> <form action="/hehe" method="post"> <input type="text" value="hehe"/> <input type="button" value="upload" id="upload"/> <!--<input type="button" value="send" onclick="send()"/>--> </form> <script> (function(){ new AjaxUpload("#upload", { action: '/hehe', type:"post", data: {}, name: 'textfield', onSubmit: function(file, ext) { alert("上传成功"); }, onComplete: function(file, response) { } }); })(); </script> </body>
The main code is posted here. After the page rendering is completed, we use a self-executing function to add an asynchronous upload event to the button with the id upload, in new AjaxUpload(id, object) The id corresponds to the id of the bound object. As for the second parameter, data is additional data. The name can be arbitrary. The onSubmit function is the
callback function before uploading the file. The first parameter file is The file name, ext is the suffix of the file, and the data returned by the server can be processed in the onComplete function. The above are two simple file upload client implementations.
What are the parameters of IE web page pop-up window
How to set the border and transparency style of Div
Solution to the invalid margin-top element in the div tag
The above is the detailed content of How to upload files asynchronously in html. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Guide to Table Border in HTML. Here we discuss multiple ways for defining table-border with examples of the Table Border in HTML.

This is a guide to Nested Table in HTML. Here we discuss how to create a table within the table along with the respective examples.

Guide to HTML margin-left. Here we discuss a brief overview on HTML margin-left and its Examples along with its Code Implementation.

Guide to HTML Table Layout. Here we discuss the Values of HTML Table Layout along with the examples and outputs n detail.

Guide to HTML Input Placeholder. Here we discuss the Examples of HTML Input Placeholder along with the codes and outputs.

Guide to the HTML Ordered List. Here we also discuss introduction of HTML Ordered list and types along with their example respectively

Guide to Moving Text in HTML. Here we discuss an introduction, how marquee tag work with syntax and examples to implement.

Guide to HTML onclick Button. Here we discuss their introduction, working, examples and onclick Event in various events respectively.
