Dynamic commit uses jquery to complete Ajax file downloads

Source: Internet
Author: User

Check a lot of information, found or not all, simply organize it yourself, at least to ensure that in my practice right, so as not to mislead readers, but also to make a record of it!

 Ajax  file Download jquery.download = function (url, data, method) {     //  Get URLs and Data    if ( url && data ) {          // data  is  string  or  array/object         data = typeof data ==  ' String '  ?  Data : jquery.param (data);        //  to assemble the parameters into  form   input        var inputs =  ';         jquery.each (Data.split (' & '),  function () {              var pair = this.split (' = ');             inputs+= ' <input type= "hidden"  name= "' + pair[0] + ' " Value= "' + pair[1] + '  /> ';          });         // request Send Request          JQuery (' <form action= ' ' + url + ' " method=" ' +  (method| | ') Post ')  + ' > ' +inputs+ ' </form> ')         .appendto (' body '). Submit (). Remove ();    };};

A daily truth
Spring Silkworm died, but left a luxurious silk; the butterfly died, but left a beautiful dress; The thrush flew away, but it left a wonderful song; The flower withered, but left a delicate fragrance; the candle burnt out, but left a bright light; the thunderstorm passed, but left a colorful neon.

That is, dynamically rendering the form, submitting the form and then deleting it. ***

Use the tuning example to implement

$.download (' exceldownload.do ', ' find=commoncode ', ' post ');

The end of the article to share some of the programmer's jokes: A qualified programmer will not write a program such as "Destroy the Earth", they will write a function called "Destroy the Planet" and the Earth as a parameter to pass in.


Dynamic commit uses jquery to complete Ajax file downloads

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.