dmallia Posted May 29, 2012 Share Posted May 29, 2012 (edited) 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 May 29, 2012 by dmallia Link to comment Share on other sites More sharing options...
justsomeguy Posted May 29, 2012 Share Posted May 29, 2012 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. 1 Link to comment Share on other sites More sharing options...
dmallia Posted May 29, 2012 Author Share Posted May 29, 2012 can you give me an example on how to call the script using ajax. I'm new to ajax. about reloading the script itself reloads the page. Link to comment Share on other sites More sharing options...
thescientist Posted May 29, 2012 Share Posted May 29, 2012 have you read any of the tutorials?http://www.w3schools.com/ajax/default.asp 1 Link to comment Share on other sites More sharing options...
dmallia Posted May 29, 2012 Author Share Posted May 29, 2012 thanks for the link 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now