我有一个 PHP 函数,可以自动存储各种对象的位置。
$(function(){
$("#sortable").sortable();
$("#sortable").disableSelection();
$('#btn').click(function(){
//var dataItem = $("#sortable").sortable("serialize");
//alert(dataItem);
$.ajax({
url: 'save-sorting-position.php',
data : dataItem,
success: function(data) {
alert('Positions saved');
}
});
});
});
然后将它们存储在 save-sorting-position.php 中,其中包括:
<?php
$arr = unserialize($_REQUEST["item"]);
foreach($arr as $index => $position)
{
//store the position here
}
?>
我想将此数组传递给表单。我尝试使用这样的东西(以实际形式):
<?php
foreach($position as $pos)
{
echo '<input type="hidden" name="item[]" value="' . $position . '>'
}
?>
但事情并没有成功。我错过了什么?谢谢!