Skip to content

Instantly share code, notes, and snippets.

View RaghavSood's full-sized avatar

Raghav Sood RaghavSood

View GitHub Profile
@DavidMah
DavidMah / filedownloader.js
Created August 30, 2012 17:03
File Download requests using jquery/POST request with psuedo ajax
// Takes a URL, param name, and data string
// Sends to the server.. The server can respond with binary data to download
jQuery.download = function(url, key, data){
// Build a form
var form = $('<form></form>').attr('action', url).attr('method', 'post');
// Add the one key/value
form.append($("<input></input>").attr('type', 'hidden').attr('name', key).attr('value', data));
//send request
form.appendTo('body').submit().remove();