如标题所述,我正在尝试通过PHP脚本提供的href URL下载一个带有相关MIME类型的文件,然后重新加载同一页,但是还不能完全弄清楚,以下是我目前拥有的内容:
<a id="viewAttachmentLink" href="/path/to/script.php?id=123">View Attachment</a>
<script type='text/javascript'>
jquery('#viewAttachmentLink').bind('click', function() {
if (myFunction()) {
window.location.href = "jquery(this).attr('href')";
setTimeout(location.reload(), 400);
} else {
return false;
}
});
</script>
使用此代码,页面将重新加载,但似乎没有调用PHP脚本。
myFunction()
是什么?2. 应该是window.location.href = $(this).attr('href');
。3. 当你已经将 href 设置为其他内容时,为什么还需要reload()
? - Brian Cray