finally I put this code:

$str = exec("ping -n 1 -w 1", $input, $result);
if ($result == 0){
echo "<img src=\"on.png\">";
echo "<img src=\"off.png\">";
It's run correctly, but i would like to insert this code into a javascript function because I insert many times this PHP and the page is very hard to load.
I would like to insert a button:

<input type="submit" onClick="para();">
and when I press this button, the javascript runs.
Is it possible??