files download without AJAX, using POST form
<table class="table table-bordered">
<tbody id="tbodyAnexos">
<?php
if($anexos)
{
foreach($anexos as $anexo)
{
?>
<tr>
<td style="width:50px;">
<button title="<?php echo L::get("visits", "apagarficheiro"); ?>"
class="btnDelete btn btn-default btn-rounded btn-condensed btn-sm"
data-id="<?php echo $anexo['iddocumento']; ?>">
<span class="fa fa-trash-o"></span>
</button>
</td>
<td><a href="#" class="doclink" data-doctype="va"
data-docname="<?php echo $anexo['iddocumento']; ?>"
target="_self"><?php echo $anexo['nomedoc']; ?></a>
</td>
</tr>
<?php
}
}
?>
</tbody>
</table>
<form id="formdocs" method="POST" action="<?php echo CFG_APPLICATION_ROOT.'/docs/' ?>">
<input type="hidden" name="type" id="doctype" value=""/>
<input type="hidden" name="name" id="docname" value=""/>
</form>
$("body").on("click", ".doclink", function(e)
{
//see/download docs
let t = $(this), doctype = t.data("doctype"), docname = t.data("docname"), target = t.attr("target");
if(target === undefined) target = "_self";
$("#doctype").val(doctype);
$("#docname").val(docname);
$("#formdocs").attr("target", target);
$("#formdocs").get(0).submit();
})