javascript - Send file as a response from ajax request -


i have javascript function sends name of audio file on server php script using jquery get. looks this:

function getaudioclip() {     var x = document.getelementbyid("clips").value;     $.get( "get_audio.php", { filename: x } )       .done(function( data ) {         loadaudioclip(data);       }); } 

the function loadaudioclip(data) displays waveform of audio file given data. want make get_audio.php return audio file file name x, can use display waveform using loadaudioclip(data) function.

edit: figured out maybe can file directly instead of using php, this

function getaudioclip() {     var x = document.getelementbyid("clips").value;     $.get( "audio/" + x , function( data ) {       loadaudioclip(data);     }); } 

is possible? x filename(ex. myrecording02.wav).

opening audio file php slow process. maybe can check existence of file php, , if file exists, this:

header("location: $filename"); 

Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -