Is there anyway to run / trigger / call a javascript (client side) from server side (PHP) ?
I can run the javascript if i call it from browser (of course, because it's client), but not from server side / postman (i wonder if there's any?)
function validate_answer($p) {
?>
<script>
$.ajax({ url: '/validate_time.php',
data: {'action': 'test'},
type: 'post',
timeout:5000
});
</script>
<?php
}
The reason i want to use this way, because in PHP, there's no such function like setTimeout like javascript does.
Thanks guys
EDIT
Okay, here's the thing. I'm creating a game that has a timeout, whenever the game starts, it will have a timelimit (10 mins example). And i need a function to do that, unfortunately, it's not accessible via browser (it's like a web service). I've tried using sleep, but it's not what i wanted.
GearmanWorker::setTimeoutfunction. This may help you. Here is the link php.net/manual/en/gearmanworker.settimeout.php