PHP - Call javascript from server side -


is there anyway run / trigger / call javascript (client side) server side (php) ?

i can run javascript if call browser (of course, because it's client), not 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 want use way, because in php, there's no such function settimeout javascript does.

thanks guys

edit

okay, here's thing. i'm creating game has timeout, whenever game starts, have timelimit (10 mins example). , need function that, unfortunately, it's not accessible via browser (it's web service). i've tried using sleep, it's not wanted.

you cannot run javascript on server side. if want effect of timeout without holding main script, can call url parameter this:

function validate_answer($p) {      $ms_delay = 5000;      file_get_contents('http://www.yoursite.com/validate_time.php?action=test&delay='.$ms_delay)  } 

and in validate_time.php @ start of file this:

sleep($_get['delay'] / 1000) 

not elegant though.


Comments

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

javascript - jQuery UI Splitter/Resizable for unlimited amount of columns -

javascript - IE9 error '$'is not defined -