Basically I have a script that checks the database every 10 seconds and notifies the user if the data has been changed using the javascript warning window. But I need the database also to be changed when the user sees a warning and clicks "OK". So is it possible to run the javascript function when the user clicks “OK” on the javascript warning?
So for example
<html>
<head>
<script type="text/javascript">
function show_alert()
{
alert("New data!");
}
</script>
</head>
<body>
<input type="button" onclick="show_alert()" value="Show alert box" />
</body>
</html>
And when the user clicks OK, he should run this function
function UpdateDB()
{
jQuery.ajax({
type: "POST",
url: "update.php",
data: 'condition=ok',
cache: false,
});
}
source
share