Reputation: 39
I'm trying to write a notification script with javascript but I get the following error when executing the js
:
Uncaught TypeError: document.title is not a function
Here's my script:
function notif() {
$.ajaxSetup({ cache: false });
$.ajax({
type:"get",
url:"cgi-bin/check",
success:function(data) {
var title;
if (data) {
if (data.indexOf("disconnected.ogg")>-1) {
if (data.indexOf("SSH")>-1) {
title = "SSH Disconnected";
}
else if (data.indexOf("VPN")>-1) {
title = "VPN Disconnected";
}
else if (data.indexOf("IP")>-1) {
title = "IP Not Found";
}
var audio = new Audio("disconnected.ogg");
audio.play();
}
else if (data.indexOf("connected.ogg")>-1) {
title = "Angel Beats!";
var audio = new Audio("connected.ogg");
audio.play();
}
$.ajax({
url:"cgi-bin/remove"
});
}
document.title(title);
}
});
setTimeout(notif, 1000);
}
notif();
How can I fix it ?
Upvotes: 2
Views: 2280
Reputation: 337580
The error is correct; title
isn't a function of the document
, it's a property.
document.title = title;
Upvotes: 3