Javascript 使用jquery播放声音通知
我使用这个功能来获取通知。我需要的是当我有新的通知时播放通知声音Javascript 使用jquery播放声音通知,javascript,jquery,audio,notifications,playback,Javascript,Jquery,Audio,Notifications,Playback,我使用这个功能来获取通知。我需要的是当我有新的通知时播放通知声音 function load_unseen_notification(view = '') { $.ajax({ url:"fetch-notification.php", method:"POST", data:{view:view}, dataType:"json", succe
function load_unseen_notification(view = '')
{
$.ajax({
url:"fetch-notification.php",
method:"POST",
data:{view:view},
dataType:"json",
success:function(data)
{
$('.dropdown-menu').html(data.notification);
if(data.unseen_notification > 0)
{
$('.count').html(data.unseen_notification);
var audio = new Audio('http://localhost/ios_notification.mp3')
audio.play()
}
}
});
}
var audio=新音频('http://localhost/ios_notification.mp3')
在这一行中,您试图调用
Audio(url)
的构造函数。您是否有运行在http://localhost:80
80
是http
的默认端口如果没有html5
,Audio
构造函数的返回值是HTMLAudioElement
,是,服务器运行在80上,运行在本地主机上。您是否可以再次检查资源()http://localhost/ios_notification.mp3“
)是否在服务器运行时实际存在并提供服务?