Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery with html / php form (using ajaxForm) working only once
    text
    copied!<p>I've been trying to solve this for a while now and no success. Stackoverflow needed!</p> <p>Basically, what the script does is fetch user profile pictures from the database. A moderator can see them and click on the "Ban" button, and then the banPeopleProcess.php file has the code to remove the picture from the database etc. Example: <a href="http://screencast.com/t/uFtFgKxYx4s" rel="nofollow">http://screencast.com/t/uFtFgKxYx4s</a></p> <p>Each picture is a form, they all have the same form id. Here's the HTML (in php echo):</p> <pre><code>&lt;div&gt; &lt;form id=\"banPeopleForm\" action=\"banPeopleProcess.php\" method=\"post\"&gt; &lt;input type=\"hidden\" name=\"toid\" value=". $i ." /&gt; &lt;input id=\"banPeopleBtn\" type=\"submit\" name=\"submit\" value=\"BAN\" /&gt; &lt;/form&gt; &lt;/div&gt; </code></pre> <p>The JS currently looks like this:</p> <pre><code>&lt;script type="text/javascript"&gt; function banPeople() { $('#banPeopleForm').ajaxForm(function() { $('#banPeopleBtn').hide(); }); } $(document).ready(function() { $('#banPeopleBtn').click(function() { banPeople(); }); }); &lt;/script&gt; </code></pre> <ul> <li>Only the first loaded picture actually does what it should be doing (button is hiding, form submitted etc.)</li> <li>For the following pictures, the JS doesn't work, they just follow the normal HTML form - when clicking the ban button, we are redirected to banPeopleProcess.php.</li> <li>With that said it seems like only the first photo id gets loaded with the JS, and the others not. I still don't know what to try.</li> </ul> <p>Help greatly appreciated guys!!</p>
 

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