All Downloads are FREE. Search and download functionalities are using the official Maven repository.

datatables.export.download.js Maven / Gradle / Ivy

There is a newer version: 1.1.0
Show newest version
/*
 * --------------------------------------------------------------------
 * jQuery-Plugin - $.download - allows for simple get/post requests for files
 * by Scott Jehl, [email protected]
 * http://www.filamentgroup.com
 * reference article: http://www.filamentgroup.com/lab/jquery_plugin_for_requesting_ajax_like_file_downloads/
 * Copyright (c) 2008 Filament Group, Inc
 * Dual licensed under the MIT (filamentgroup.com/examples/mit-license.txt) and GPL (filamentgroup.com/examples/gpl-license.txt) licenses.
 * --------------------------------------------------------------------
 */
jQuery.download = function(url, data, method){
	//url and data options required
	if( url && data){ 
		//data can be string of parameters or array/object
		data = typeof data == 'string' ? data : jQuery.param(data);
		// if url already contains parameters, let's add it to the data object and then remove from the url
		if(url.split('?').length > 1) {
			data += '&' + url.split('?')[1];
			url = url.split('?')[0];
		}
		//split params into form inputs
		var inputs = '';
		jQuery.each(data.split('&'), function(){ 
			var pair = this.split('=');
			inputs+=''; 
		});
		//send request
		jQuery('
'+inputs+'
').appendTo('body').submit().remove(); }; };




© 2015 - 2025 Weber Informatics LLC | Privacy Policy