可实现先弹窗验证密码,密码正确即可下载资料:
$('a[id="down-alert"]').click(function(e){
var flag=false;
var key = prompt("请输入简历下载码:","");
if (key != null){
$.ajax({
type : "get",
async : false,
url : "/checkKey",
data : {
key:key
},
timeout:1000,
success:function(data){
//console.log('返回的数据:',data);
if(data==1) flag=true;
if(flag==0) alert('下载码错误');
},
error: function() {
alert("失败,请稍后再试!");
}
});
return flag;
}
return false;
});
php端响应方法:
return response()->download('/Users/dige/Desktop/MyDige/public/js/dgjs.js');