$.ajax({
type: "POST",
url: "processform.php",
dataType: "json",
data: {name: name, email: email, city: city, country: country, day: day, month: month, year: year}
}).done(function(msg){
if(msg.success == 1){
$("#success_msg").append('<p>'+msg.message+'</p>');
window.location.href = './music/song.mp3';
}
});
上面的代码只是用音乐播放器加载新页面。我希望它像文件一样下载。在ajax调用完成后开始下载文件
pecl_http中的http_send_file非常有用 - 为范围请求和http_match_etag启用自动响应304(未修改)。 http://php.net/manual/en/function.http-send-file.php和http://php.net/manual/en/function.http-match-etag.php – Olli 2012-04-15 13:26:17