jQuery代码
$(function() {
$("#list .sections").sortable({ opacity: 0.5, cursor: 'move',update: function() {
var order = $(this).sortable("serialize") + '&update=order';
$('#form').submit(function()
{
$.ajax
({
type: "POST",
url: "update.php",
data: order,
success: function()
{
alert(success)
}
});
});
}
});
});
HTML 和 PHP 代码
<form action="" method="post" id="form">
<div id="list">
<div class="sections">
<div id="response"> </div>
<?php
include("connection.php");
$query = "SELECT * FROM dragdrop ORDER BY listnumber ASC";
$result = mysql_query($query);
while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
$id = stripslashes($row['id']);
$text = stripslashes($row['text']);
?>
<div id="listOrder_<?php echo $id ?>" class="box_inner">
<div id="section_head">
<?php echo $text?>
<span class="id"><?php echo $id; ?></span>
<input type="hidden" name="value" value="need value" />
</div>
<div id="section_body">
<h2> Drag Me </h2>
</div>
</div>
<?php } ?>
</div>
<input type="submit" id="save_element" value="Save element" style="margin-left: 40px" />
</div>
</form>
我的问题是如何通过序列化获取 listOrder_ id 下的所有值?
我尝试过
var value = $('input[name="value"]').val();
$.(value).sortable("serialize");
但不能让它工作,请帮助我
谢谢