Iam using ajax method for fetching data from a page users.php and the results from this page are set as html inside a div in parent page list-users.php
The users.php returns the html like below
<table width="100%" border="0">
<tr>
<td>John<input name="user_id[]" type="hidden" value="1" /></td>
</tr>
<tr>
<td>Sam<input name="user_id[]" type="hidden" value="2" /></td>
</tr>
</table>
These values are put inside a div using $("#userlists").html();
in list-users.php
<form method="post">
<div id="userlists">
<table width="100%" border="0">
<tr>
<td>John<input name="user_id[]" type="hidden" value="1" /></td>
</tr>
<tr>
<td>Sam<input name="user_id[]" type="hidden" value="2" /></td>
</tr>
</table>
</div>
<input type="submit" name="submit_users" value="Save" />
</form>
When I submit the form, the user_id[]
always returns empty. I don't know what the error is. Is it possible to get the values of user_id[]
while submitting form?
<?php
if(isset($_POST['submit_users']))
{
print_r($_POST['user_id']);
//this returns empty data always
}
?>
var value='{"slno":"'+number+'","empcode":"'+code+'"}';
jQuery.ajax({
type: 'POST',
url: 'inc/users.php',
data: 'values='+value,
cache: false,
success: function(html){
if(html)
{
$("#userlists").html(html);
}
else
{
$("#userlists").html("Error Occured.");
}
}
});