Reputation: 193
I want to do this, I have a tag with a href attr that in normal sense would download a file, but I want to make it downloaded after change some info in the web page look at this code:
This is the html where I have the html and where the user can download a file.
<li class="imprimir"><h2><a href="javascript:descargarNoticia()" id="descargar" >Descargar Noticia</a></h2></li>
And here the JS that would change information and then download the file but I cant do that.
function descargarNoticia(){
$.post("http://www.xxx.com/noticia/datosUsuarios",
function(data){
$("#empresa").show();
$("#email").html(data['email'])
$("#telefono").html(data['telefono'])
$("#direccion").html(data['direccion'])
$("#empresa").html(data['empresa'])
var words = $('#wrapper-960').text().split(' ').length;
var alto=words*0.264583333;
$("#descargar").attr("href","http://pdfcrowd.com/url_to_pdf/?width=500mm&height="+alto+"mm")
}
},'json');
};
Thanks.
Upvotes: 0
Views: 310
Reputation: 2056
Can you not just go to that URL after changing it?
var URL= "http://pdfcrowd.com/url_to_pdf/?width=500mm&height="+alto+"mm";
$("#descargar").attr("href",URL)
window.location = URL;
Upvotes: 1
Reputation: 37389
If you have the address of the file, just open that address:
window.open("http://...");
EDIT: Damn, ctrl-alt-dileep beat me to it.
Upvotes: 1