I am working on system which require sound notification when new store is made.I am all right with AJAX part, sound works when I have open my system in PC, but does't work when I tried in a iPad with Chrome and Safri, even in a Android device with Google Chrome, is my code not ok, or it is not supportable in other devices?
My code:
if(typeof(EventSource) !== "undefined") {
var source = new EventSource($('meta[name="base_url"]').attr('content') +'/notification_ajax');
var audio = new Audio('assets/file.mp3');
source.onmessage = function(event) {
var myarr = event.data.split(",");
if(parseInt(myarr[1]) != parseInt(myarr[0])){
audio.play()
var url = $('meta[name="base_url"]').attr('content') +'/update_file';
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
$.post(url,
{old_count: myarr[1]
},
function (data) {
})
};
}}
Thanks in advance!
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire