Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You could use <code>jQuery.ajax()</code> and set the option <code>async</code> to false:</p> <blockquote> <p><strong>async</strong> Default: true By default, all requests are sent asynchronously (i.e. this is set to true by default). If you need synchronous requests, set this option to false. Cross-domain requests and dataType: "jsonp" requests do not support synchronous operation. Note that synchronous requests may temporarily lock the browser, disabling any actions while the request is active</p> </blockquote> <p>You could use it like this:</p> <pre><code>$.ajax({ type: "POST", url: "file.php", async: false, data: data, success: function(return){ alert("Success: "+return); } }); </code></pre> <p>If you want to add a loader just apply it as:</p> <pre><code>startLoader(); $.ajax({ type: "POST", url: "file.php", async: false, data: data, success: function(return){ alert("Success: "+return); } }); endLoader(); </code></pre> <p>However you PHP idea is simply not a good one. Opening a session and do all the process for this kind of thing is just useless and slow your script down. You should be asking yourself: Do I really need to block this?</p> <p>If the answer is yes then do this: Create a table called <code>processes</code> in you database. Inside that table create 2 fields: One will be the process identifier: <code>process_id</code>; the second will be the process status: <code>process_status</code>. The first is an integer you will define with sha1(IMAGE). The second will be an integer: <code>1</code> for "busy", <code>0</code> for "free".</p> <p>Then you could do something like this:</p> <pre><code>SELECT process_status FROM vps_processes WHERE process_id = sha1(CURRENT_IMAGE); </code></pre> <p>And check whatever it is <code>1</code> or <code>0</code>. If it is <code>1</code> then block the script; If it is <code>0</code> then you query:</p> <pre><code>UPDATE vps_processes SET process_status = 1 WHERE process_id = sha1(CURRENT_IMAGE); </code></pre> <p>then run what you have to run and at the end of the script query:</p> <pre><code>UPDATE vps_processes SET process_status = 0 WHERE process_id = sha1(CURRENT_IMAGE); </code></pre>
    singulars
    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.
 

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