Marc
Marc

Reputation: 9527

PHP Jquery - kill php script that was launch using an ajax call in jquery

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

Upvotes: 1

Views: 376

Answers (2)

dweeves
dweeves

Reputation: 5605

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

Upvotes: 1

dweeves
dweeves

Reputation: 5605

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)

Upvotes: 0

Related Questions