Javascript
<script>
$(document).ready(function(){//So far AJAX isn't asyncn.
$(".acceptorbutton").on('click', function(){
var whichClicked = this.attr('name');
var cat = parseInt(whichClicked, 10);
alert("this text is not appearing");
$.ajax({
type:"POST",
url:"getuser.php",
data: {friendadd : cat},
success: function(){
alert("Ajax success");
}
})
})
});
</script>
PHP and HTML Form: It is looping through for every user that the search result turns up. Next to each user is an input button that onClick should call getuser.php. The Input buttons are identical except for they're names. On the click, the jQuery should execute yet it does not detect it
<form id="friendadd" enctype="multipart/form-data">
<?php
for($i=0; $i<$ctk->rowCount(); $i++){
echo "<img src='".$ctk_values[$i][6]."' alt='Blank' style='width:64px;height:64px'>";//PP, Later add clickable profile
echo "<th rowspan='3'>Attributes</th>";
echo "<tr> ".$ctk_values[$i][0]."</tr>";//UN
echo "<tr> ".$ctk_values[$i][1]."</tr>";//UL
echo "<tr> ".$ctk_values[$i][5]."</tr>";//UA
echo "YOYOYOO".$ctk_values[$i][4];
$GlobalAcceptorId=$ctk_values[$i][4];
?>
<div id="dom-target" style="background-color:yellow;">
<?php
echo $GlobalAcceptorId;
?>
</div>
<input class="acceptorbutton" type="button" name="<?php echo $ctk_values[$i][4];?>"><br>
<?php
}//Ends for loop
?>
</form>
<?php
}
}
?>
What I've tried so far: the alert box isn't appearing. I've tried changing the form button type to submit and made the Javascript $(".acceptorbutton").submit(function(){....
Thanks in advance! Please let me know if you need more information but so far I don't think I'm missing any critical data
Aucun commentaire:
Enregistrer un commentaire