Iam使用ajax方法从页面users.php获取数据,并将此页面的结果设置为父页面div中的html内容列表users.php
的users.php返回像下面
<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>
这些值在列表users.php把使用$("#userlists").html();
一个DIV中的HTML
<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>
当我提交表格时,user_id[]
总是返回空白。我不知道错误是什么。提交表单时可以获得user_id[]
的值吗?
<?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.");
}
}
});
分享php代码也。和ajax代码。 – isnisn
你如何处理提交?通过ajax或你正在阅读$ _POST数组? – mitkosoft
Iam使用$ _POST – Anoop