javascript - Using a file created by PHP with jquery -


i using jquery post string php file this:

$.ajax({         type: "post",         url:"save0.php",         data: {data:subtitle}, success: function() {        console.log("message sent!")}  }); 

the php file writes .vtt (subtitle) file , file loaded track element of looping html5 video. every time video loops has different subtitle:

$("#subtitles").attr("src", "subtitle/sub1.vtt"); 

i use following line delete last track src (otherwise video doesn't loop):

$("#subtitles").removeattr("src"); 

unfortunately doesn't work, seems subtitle can used when browser refreshed. when video tries loop gets stuck, because cannot find track src element (i've been debugging while). freshly written files can used after refresh? or there alternative way 'load' newly written files?

i fixed alternating between subtitle files:

$("#subtitles").removeattr("src"); if (subcounter == "ae"){                 $.ajax({type: "post",url:"save0.php",data: {data:subtitle},success: function() {console.log("message sent!")}});             $("#subtitles").attr("src", "subtitle/sub1.vtt");             console.log("true"); }; if (subcounter == "ea"){             $.ajax({type: "post",url:"save1.php",data: {data:subtitle},success: function() {console.log("message sent!")}});             $("#subtitles").attr("src", "subtitle/sub0.vtt");             console.log("false"); }; 

then @ end of loop reverses subcounter string:

function reverse(s){     return s.split("").reverse().join("");     };  subcounter = reverse(subcounter); 

Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -