$.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呼び出し完了後にファイルをダウンロードし始めます。
http_send_fileをpecl_httpから実行すると便利です - 範囲リクエストを有効にし、自動304(変更しない)レスポンスでhttp_match_etagを有効にします。 http://php.net/manual/en/function.http-send-file.phpおよびhttp://php.net/manual/en/function.http-match-etag.php – Olli