I've been trying to solve this for a while now and no success. Stackoverflow needed!
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: http://screencast.com/t/uFtFgKxYx4s
Each picture is a form, they all have the same form id. Here's the HTML (in php echo):
<div>
<form id=\"banPeopleForm\" action=\"banPeopleProcess.php\" method=\"post\">
<input type=\"hidden\" name=\"toid\" value=". $i ." />
<input id=\"banPeopleBtn\" type=\"submit\" name=\"submit\" value=\"BAN\" />
</form>
</div>
The JS currently looks like this:
<script type="text/javascript">
function banPeople() {
$('#banPeopleForm').ajaxForm(function() {
$('#banPeopleBtn').hide();
});
}
$(document).ready(function() {
$('#banPeopleBtn').click(function() {
banPeople();
});
});
</script>
Help greatly appreciated guys!!
You should prevent form
from submitting php file and use ajax for calling your php.something like that
$(document).ready(function() {
$('#banPeopleBtn').click(function(e) {
e.preventDefault();
banPeople();
$.ajax({
type: "POST",
url: "banPeopleProcess.php"
});
});
});
Use different id for each picture. use different form id and submit id for each picture. Make dynamic the javascript id as well as followed $('#banPeopleBtn'+id).hide(); As javascript can not work with same id in same page.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.