I have the following hidden input field with a dynamic value.
<input id='max' type='hidden' value='<?php echo $num_rows; ?>'>
I'm wanting to update that value based on $num_rows that are returned from a ajax_load_profile_friends.php
page.
Here is what I have so far:
$("#viewAllFriends").click(function(){
counter = counter+16;
$.ajax({
url:'includes/handlers/ajax_load_profile_friends.php',
type:'POST',
data:{'username':username, 'num_friends':num_friends, 'counter':counter},
success: function(data) {
$('#data_friends').html(data);
$('#max').val("??");
}
});
});
With each successive click of View More Friends button, I get a new value for $num_rows
. Being new to Ajax I'm not sure how to return it to the success function and then update the value
in the hidden input.
$num_rows
returns like this $num_rows = $result->num_rows;
in ajax_load_profile_friends.php
.
This is part of a larger problem I was having earlier but have narrowed it down to this and tried to simplify my question. Any help, examples, links would be super!