Reputation: 9527
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
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