Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If you want to use the ajax request handlers, an id will need to be assigned (manually or automatically) to the element that triggered the event. You could then send this id as an additional key-value pair in the request (element_id:THEID) and grab it with various substring methods in the ajax request handlers.</p> <p>Example:</p> <pre><code>&lt;script type="text/javascript"&gt; $(document).ready(function(){ $("input").click(function(){ var newid = (create a custom id with date and time); $(this).attr("id", newid); $.post("handler.php", {element_id : $(this).attr("id")}); }); }).ajaxSend(function(e, xhr, settings){ var start_position = settings.data.indexOf("element_id"); var equalsign_position = settings.data.indexOf("=", start_position); var ampersand_position = settings.data.indexOf("&amp;", start_position); var element_id; if(ampersand_position == -1){ element_id = settings.data.substr(equalsign_position+1); } else { element_id = settings.data.substr(equalsign_position+1, ampersand_position-equalsign_position-1); } $("#"+element_id).after("&lt;div id='div"+element_id+"'&gt;&lt;img src='loading_start.png' /&gt;&lt;/div&gt;"); }).ajaxComplete(function(e, xhr, settings) { var start_position = settings.data.indexOf("element_id"); var equalsign_position = settings.data.indexOf("=", start_position); var ampersand_position = settings.data.indexOf("&amp;", start_position); var element_id; if(ampersand_position == -1){ element_id = settings.data.substr(equalsign_position+1); } else { element_id = settings.data.substr(equalsign_position+1, ampersand_position-equalsign_position-1); } $("#div"+element_id).remove(); }); &lt;/script&gt; &lt;input type="button" value="Save" /&gt; </code></pre> <p>The alternative is handling the appearing and disappearing of the loading image in each event handler (but I seem to understand you have too many of them?), like this:</p> <pre><code>&lt;script type="text/javascript"&gt; $(document).ready(function(){ $("input").click(function(){ var element_id = (generate custom id); $(this).after("&lt;div id='div"+element_id+"'&gt;&lt;img src='loading_start.png' /&gt;&lt;/div&gt;"); $.post("handler.php", {var:"hello"}, function(){ $("#div"+element_id).remove(); }); }); }) &lt;/script&gt; </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.
    3. 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