Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery: form returned on "success" needs re-binding
    primarykey
    data
    text
    <p>a quick question. I am using the jQuery.forms.js plug-in. </p> <p>I have a form that posts to a php page and returns data with jSon. </p> <p>The data that is returned is code for a new form (it replaces the form that was used to post the information). The new form is not bound to any jQuery functions, as it was not around when the page loaded. </p> <p>So, how can I get ajax form to recognize the new form, so that if i need to use the form a second time, it is also utilizing the jQuery function?</p> <pre><code>// jQuery for submitting info to php doc and, on success, replacing the form $(document).ready(function() { jQuery('form[id*=postOnline]').ajaxForm({ dataType: 'json', success: function(data) { $('#onlineStatus' + data.rid).html(data.formed).slideDown('slow'); bindNote(); } }); }); &lt;!-- /////////////////////// POST ONLINE /////////////////////// --&gt; &lt;div id='onlineStatus&lt;?php echo $b_id ?&gt;' class='postOnline'&gt; &lt;form name="postOnline" id="postOnline&lt;?php echo $b_id ?&gt;" action="postOnline.php" method="post"&gt; &lt;input type="hidden" value="&lt;?php echo $b_id ?&gt;" name="b" /&gt; &lt;input type="hidden" value="1" name="p" /&gt; &lt;input type="submit" class="button" value="Post Online" /&gt; &lt;/form&gt; &lt;/div&gt; &lt;!-- /////////////////////// POST ONLINE /////////////////////// --&gt; // ... code for entering data into database and then... $result = mysql_query( $sql ); if($result) { if($show == '1'){$val = 'remove from online'; $num='0';} if($show == '0'){$val = 'show online'; $num='1';} $return = " &lt;form name='postOnline' id='postOnline$id' action='postOnline.php' method='post'&gt; &lt;input type='hidden' value='$b_id' name='b' /&gt; &lt;input type='hidden' value='$num' name='p' /&gt; &lt;input type='submit' class='button' value='$val' /&gt; &lt;/form&gt; "; print json_encode(array("rid" =&gt; $id, "formed" =&gt; $return)); } ?&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. 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