Generally used under the file
window.location.href= ' xxx '
But sometimes passing parameters to the background requires
window.location.href= ' xxx?name=123&age=234 '
It's a little unreasonable to have too many passes or too much length of argument.
jquery.download = function (URL, data, method) {//Get URL and data
if (URL && data) {
//data is string or array/ Object
data = typeof data = = ' string '? Data:jQuery.param (data);//input
var inputs = ' To assemble parameters into form;
Jquery.each (Data.split (' & '), function () {
var pair = this.split (' = ');
inputs+= ' <input type= "hidden" name= "' + pair[0] + '" value= "' + pair[1] + '"/> ';
} "; Request to send requests for
jQuery (' <form action= ' + URL + ' method= ' + (method| | ') Post ') + ' > ' +inputs+ ' </form> '). Appendto (' body '). Submit (). remove ();};
$.download (' url ', ' data ', ' post ');
This method downloads files by creating a from form for mock data requests
which uses the JQuery Ajax-param ()
var params = {width:1900, height:1200};
var str = Jquery.param (params);
Console.log (str)
width=1680&height=1050//Output results
The Param () method creates a serialization representation of an array or object, specifically to look up the manual.