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