I'd like to download a doc file when I click on button. Also, this doc file is generated from a php code.
I have the following HTML
, jQuery
and PHP
code but without success:
<li><a href="" id="docFormat">DOC</a></li>
<script>
$('#docFormat').on('click', function(event) {
'<?php' +
'header("Content-type: application/vnd.ms-word");' +
'header("Content-Disposition: attachment; filename=TablaSectores.doc");' +
'echo "<table id="sectoresTable"><thead><tr><th><b>#</b></th><th><b>Numero</b></th><th><b>Nombre</b></th></tr></thead><tbody></tbody></table>";' +
'?>'
});
</script>
When I click on the button, it isn't download nothing. I'm not sure what is wrong.
Any idea?