This article mainly introduces jQuery's Non-Use of plug-ins and swf to implement brushless newest File Upload. If you need it, you can refer to the file upload function, which is a common function of the website, such as the attachment or image upload function, there are also many solutions. Today we will introduce a new file upload method through jQuery.
First, we put a form in the page to upload files:
The Code is as follows:
Then, put an iframe in the page and refresh the iframe when uploading, instead of the entire webpage:
The Code is as follows:
Next, use js to add the button function:
The Code is as follows:
Script
$ (Function (){
$ ("# BtnUpload"). click (function (){
$ ("# MyForm"). submit ();
});
});
Script
Click the button to submit the form.
This scheme can be used to easily implement non-refreshing file uploads. The implementation idea is: submit the form to an iframe, And the other processing is like processing a common form commit.
To be improved, we have only one idea: Listening to the readystate of iframe through js and parsing the content of iframe.