Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This is good only in case you are processing really massive data loads through AJAX. For other cases, just handle it in JS to not display result if canceled.</p> <p>But as I said If you are processing huge loads of data, then you can add a interrupt condition in every nth step of running script and fulfill that condition using another script. For example you can use a file to store a interrupt data, or MySQL MEMORY table.</p> <p>Example.</p> <p>1, process.php (ajax script processing loads of data)</p> <pre><code>// clean up previous potential interrupt flag $fileHandler = fopen('interrupt_condition.txt', 'w+'); fwrite($fileHandler, '0'); fclose($fileHandler); function interrupt_check() { $interruptfile = file('interrupt_condition.txt'); if (trim($interruptfile[0]) == "1") { // read first line, trim it and parse value - if value == 1 interrupt script echo json_encode("interrupted" =&gt; 1); die(); } } $i = 0; foreach ($huge_load_of_data as $object) { $i++; if ($i % 10 == 0) { // check for interrupt condition every 10th record interrupt_check(); } // your processing code } interrupt_check(); // check for last time (if something changed while processing the last 10 entries) </code></pre> <p>2, interrupt_process.php (ajax script to propagate cancel event to file)</p> <pre><code>$fileHandler = fopen('interrupt_condition.txt', 'w+'); fwrite($fileHandler, '1'); fclose($fileHandler); </code></pre> <p>This will definitely affect performance of your script, but makes you a backdoor to close execution. This is very simple example - you need to make it more complex to make it work for more users simultaneously, etc.</p> <p>You can also use <strong>MySQL MEMORY Table</strong>, <strong>MEMCACHE - Non-persistent Caching Server</strong> or whatever non-persistent storage you could find. </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload