From 1c127236bd8d41997a8566651e9361623c308aa3 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Tue, 23 Apr 2013 14:42:13 +0200 Subject: [PATCH] =?utf8?q?jQuery-Script/Methode=20zum=20Ansto=C3=9Fen=20vo?= =?utf8?q?n=20Downloads?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- SL/Form.pm | 2 +- js/jquery.download.js | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 js/jquery.download.js diff --git a/SL/Form.pm b/SL/Form.pm index 5af4dc287..d1d4315ca 100644 --- a/SL/Form.pm +++ b/SL/Form.pm @@ -475,7 +475,7 @@ sub header { ); $layout->use_javascript("$_.js") for (qw( - jquery jquery-ui jquery.cookie jqModal jquery.checkall + jquery jquery-ui jquery.cookie jqModal jquery.checkall jquery.download common part_selection switchmenuframe ), "jquery/ui/i18n/jquery.ui.datepicker-$::myconfig{countrycode}"); diff --git a/js/jquery.download.js b/js/jquery.download.js new file mode 100644 index 000000000..54ffb6afd --- /dev/null +++ b/js/jquery.download.js @@ -0,0 +1,19 @@ +jQuery.download = function(url, data, method) { + //url and data options required + if (!url || !data) + return; + + //data can be string of parameters or array/object + data = typeof data == 'string' ? data : jQuery.param(data); + //split params into form inputs + var form = jQuery('
'); + jQuery.each(data.split('&'), function(){ + var pair = this.split('='); + var input = jQuery(''); + input.attr('name', decodeURIComponent(pair[0])); + input.val(decodeURIComponent(pair[1])); + input.appendTo(form); + }); + //send request + form.appendTo('body').submit().remove(); +}; -- 2.20.1