I have a form that does a http-get which returns a file. If I simply use the in-built get from form the browser attempts to download the file, which is what I want. However, I want to do the http-get through jQuery so that I can display a loading bar that terminates when the get has finished its request. (Request takes ~20 seconds)
I do the request like this:
$('#dagens').on('submit', function (event) {
event.preventDefault();
nanoBar.go(50);
console.log("NProgressShouldHaveStarted")
$.get( $(this).attr('action'), function( data ) {
$( ".result" ).html( data );
console.log( "Loadwasperformed.");
nanoBar.go(100);
});
});
I gather that the file resides in 'data', but how can I pass this to the browser so that it prompts the user to download it?