Revision 1c127236
Von Moritz Bunkus vor mehr als 11 Jahren hinzugefügt
SL/Form.pm | ||
---|---|---|
475 | 475 |
); |
476 | 476 |
|
477 | 477 |
$layout->use_javascript("$_.js") for (qw( |
478 |
jquery jquery-ui jquery.cookie jqModal jquery.checkall |
|
478 |
jquery jquery-ui jquery.cookie jqModal jquery.checkall jquery.download
|
|
479 | 479 |
common part_selection switchmenuframe |
480 | 480 |
), "jquery/ui/i18n/jquery.ui.datepicker-$::myconfig{countrycode}"); |
481 | 481 |
|
js/jquery.download.js | ||
---|---|---|
1 |
jQuery.download = function(url, data, method) { |
|
2 |
//url and data options required |
|
3 |
if (!url || !data) |
|
4 |
return; |
|
5 |
|
|
6 |
//data can be string of parameters or array/object |
|
7 |
data = typeof data == 'string' ? data : jQuery.param(data); |
|
8 |
//split params into form inputs |
|
9 |
var form = jQuery('<form action="'+ url +'" method="'+ (method||'post') +'"></form>'); |
|
10 |
jQuery.each(data.split('&'), function(){ |
|
11 |
var pair = this.split('='); |
|
12 |
var input = jQuery('<input type="hidden"/>'); |
|
13 |
input.attr('name', decodeURIComponent(pair[0])); |
|
14 |
input.val(decodeURIComponent(pair[1])); |
|
15 |
input.appendTo(form); |
|
16 |
}); |
|
17 |
//send request |
|
18 |
form.appendTo('body').submit().remove(); |
|
19 |
}; |
Auch abrufbar als: Unified diff
jQuery-Script/Methode zum Anstoßen von Downloads