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.

Edited by dmallia
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.

  • Like 1
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...