Need one more litle help. I want to pass my variable from php to javascript function with desktop notification. But how i try still cant get it.
<script type="text/javascript">
function notifyMe(lol) {
var v = lol;
if (!Notification) {
alert('Please us a modern version of Chrome, Firefox, Opera or Firefox.');
return;
}
if (Notification.permission !== "granted")
Notification.requestPermission();
var notification = new Notification('Jums sukurta nauja užduotis!', {
icon: 'task.png',
body: v,
timeout: 3000,
tag: '24',
});
}
</script>
<?php
$id = "123";
echo '<script type="text/javascript">var lol = $id </script>';
echo '<button id="myLink" onclick="notifyMe(lol)">Notify me!</button>';
?>
Try changing
to
In your script you are actually sending "lol" as text, not the value of $ID. You can check this by right clicking on the browser after you have loaded the html, and displaying the source code. Find this line and check that it is doing what you think it is doing.