Reputation: 485
I've read that there is no way that JQuery can download a file directly, so far I was handling the situation by using iframes which worked perfectly for my situation. But now, the requirement has changed, and the file creation is being protected with authentication. I need a way to send the authorization header along with the iframe src request or some other way to do this, since ajax is not an option. And I want to keep this as a single step, any ideas of how to handle this?
BTW ... PHP scripts are not an option.
Thank you
Upvotes: 2
Views: 2251
Reputation: 5106
You don't specify which kind of authentication is in use, but for basic authentication you can try accessing the URL like this:
This will send the header without the need to set anything using jQuery.
Keep in mind that doing something like this client-side, jQuery or not, exposes the credentials.
Upvotes: 3