내 웹 서비스에 대한 알림을 보냈습니다. 코드는 (처음 두 행은 정신 바로 가기 있습니다) 다음과 같습니다 : 나는 두 개 이상의 경보가있을 때자바 스크립트 - 웹 브라우저의 알림 API
check_how_many_alerts();
loop count(check_how_many_alerts){
var n = new Notification("Alert!",{ icon: "alert.png", body: variable });
alert_name = variable;
n.onshow = function() {
setTimeout(n.close.bind(n), 10000);}
n.onclick = function() {
$.ajax({
url: 'notif_accept.php',
type: 'GET',
data: 'id=' + alert_name,
success: function(output)
{
alert('success, server says '+output);
}, error: function()
{
alert('something went wrong');
}
});
}
}
문제는, 그들 모두가 .onclick 기능에서 같은 URL이 있습니다. "alert_names"가 다른 URL을 사용하려면 어떻게해야합니까?
당신이 원하는 것은 동적Notification
의 프로토 타입에 메서드를 추가, 당신이 AJAX 호출에 대해
url: 'notif_accept.php'
있어 지정하는 경우
URL의 당신이 무엇에 관해 얘기하는지 모른다. 표시된 코드에는 URL의 – charlietfl