Jump to content
Sign in to follow this  
dmallia

get php script using javascript onclick

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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...