Note that there are some explanatory texts on larger screens.

plurals
  1. POAjax request only handling once
    primarykey
    data
    text
    <p>I have a table which has rows like in the image below. When the order online link is clicked, a form is displayed just below the row as in second image.</p> <h2>FIRST IMAGE</h2> <p><img src="https://i.stack.imgur.com/AOqi6.jpg" alt="enter image description here"></p> <h2>SECOND IMAGE</h2> <p><img src="https://i.stack.imgur.com/PL2yJ.jpg" alt="enter image description here"></p> <p>Now the thing that I am doing is initiating a ajax request when the submit button is clicked. The request is successful in the first instance. But when the request is issued again it does not work. It works for the same <code>&lt;tr&gt;</code> but when the order online of second <code>&lt;tr&gt;</code> is clicked and the form is loaded below that <code>&lt;tr&gt;</code> then, the submit ajax wont work,</p> <pre><code> $(document).ready(function(){ var $form = $('.form'), $table = $('.table'); $table.on('click', '.link', function(e) { e.preventDefault(); $table.find('tr.temp-row').remove(); $(this).closest('tr').after(function() { var $tr = $('&lt;tr class="temp-row"&gt;&lt;td colspan="4"&gt;&lt;/td&gt;&lt;/tr&gt;'); return $tr.find('td').html($form).end(); }); }); $("#cancel").click(function(){ $form.hide(); }); $("#submit").click(function(){ var request = $.ajax({ url: "processform.php", type: "POST", //data: {msg : msg}, dataType: "html" }); request.done(function(msg) { //$("#log").html( msg ); alert(msg); }); request.fail(function(jqXHR, textStatus) { alert( "Request failed: " + textStatus ); }); return false; }) }); </code></pre> <p>my <code>processform.php</code> page just returns some text which is alerted in the page which requests it.</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. 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