I have the following ajax function:
var data=event.target.result;
var fileName=encodeURIComponent('audio_recording_' + new Date().getMinutes() + '.wav');
$.ajax({
type: 'POST',
url: 'readFile.php',
data: {"fileName":fileName,"data":data},
success: function(data){
console.log(data);
}
});
the server-side code
<?php
$fileName=$_POST["fileName"];
$data=$_POST["data"];
$dh = opendir('upload/');
$contents = file_get_contents('C:/wamp/www/JSSoundRecorder/upload/'.$fileName);
// echo $contents;
echo $fileName;
echo $data;
In the console.log(data) i'm obtaining the correct results (filename and data) what I want is to have each info alone to use later. that is fileName in a variable and data in another variable in the success function so that I can use them later in the program.I think I should use maybe localstorage and json.stringify??is that correct.or is there another way.and if that is true can you help me how to use localstorage here? thank you in advance