嗨,我目前正在使用以下方法保存 div
Javascript
$(document).ready(function(){
$( ".ex" ).draggable({containment:'parent',cursor:'pointer',opacity:0.6,
stop : function () {
var id = $(this).attr("id");
var x = $(this).position().left;
var y = $(this).position().top;
$.ajax({
url: "changeContact.php", /* You need to enter the URL of your server side script*/
type: "POST",
/* add the other variables here or serialize the entire form.
Image data must be URI encoded */
data:{
cid:id,
x: x,
y: y
},
success: function(msg)
{
}
})
}
});
});
PHP
$qry = "SELECT * from contact Where CustomerID='$pid'";
$result = mysql_query($qry);
while ($row = mysql_fetch_array($result))
{
echo '<div class="ex" id="'.$row["ContactID"].'">';
echo '</div>';
}
页面onload时如何分别保存每条数据的位置?有没有什么方法可以自己调用Ajax方法而不拖拽?