JQuery does not use plug-ins or swf to upload non-refreshing files _ jquery-js tutorial

Source: Internet
Author: User
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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.