Jump to content

get php script using javascript onclick


dmallia

Recommended Posts

I have this php script stop.php

<?phpinclude('ssh_con.php');$stop = 'screen -S testapplication -X quit';ssh2_exec($con, $stop);mysql_query("UPDATE servers SET Online=0 WHERE Owner='".$_SESSION['Username']."'");echo "<meta http-equiv='refresh' content='0;index.php'>";?>

now i want to execute/call/get this page/script using javascript onclick to execute the code and the page refreshes itself. Can anyone guide me to do this? Thanks before hand.

Link to comment
Share on other sites

You need to send an ajax request to run that script and get the output. Instead of having it output a meta tag, have it output something like "success" or "true" if everything went OK, or else have it output an error message that you can show. In the ajax response handler you can check to make sure the request succeeded and then use window.location.reload to refresh the page, or set window.location.href to redirect.

Link to comment
Share on other sites

thanks for the link :D I was searching only under javascript not ajax >.< made a simple script and seems to work. I will test it with my script and see what happens. Thanks again.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...