1

I have a button on my page. When clicked it triggers an ajax call using the ajax method of jquery. The php script runs loops that insert data into my db. My problem that I want to kill that script from running but I don't know how to do. Hope someone can help. Thank you in advance. Cheers. Marc

8
  • Possible Duplicate of: stackoverflow.com/questions/446594/… Commented Mar 19, 2012 at 13:49
  • 1
    Can you be more specific? How do you want to kill it? What exactely do you mean by "killing"? Commented Mar 19, 2012 at 13:49
  • Hello Ben. The thing is I did not gave a variable to my ajax call. So I can't use the technic your are suggesting. But I still need to kill the script that has been launched... Commented Mar 19, 2012 at 13:50
  • Hello Rob. By killing I mean stop it. The thing is my loop runs ten thousand of times. It is currently looping and I need to stop it. Hope I am clear... Commented Mar 19, 2012 at 13:52
  • 1
    The problem is if you don't assign the call to a variable, then you'll have no simple way of interacting with it once it's in progress Commented Mar 19, 2012 at 13:55

2 Answers 2

1

To kill a running php script : restart the web server.

Sign up to request clarification or add additional context in comments.

Comments

0

I would recommend:

  • in your looping script,at each loop, test for a session variable or a persisted value of any type (file, db) that would store a cancel flag. if this flag is set,break the loop this would abort the processing.

  • create another script (cancel.php) for example, that will set this cancel flag in the storage (session,file or db). this cancel script will be called via your ajax request.(of course , if you used session to store the cancel flag, don't forget to pass the same sessionid than your looping script as parameter of your ajax request)

3 Comments

Hello dweeves. Thanks for the reply. As mentionne, in the furutre I will put my ajax call in var so I can use the jquery abort() method. But now it is too late. The script is currently under execution and I need to find a way to stop it...
in that case, restart the web server !
Put it as answer instead of what you suggested in the first place. An accepted answer is waiting for you...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.