【发布时间】:2011-05-29 18:28:49
【问题描述】:
为了便于阅读,我已经剪掉了部分代码。当通过拖动 col_1 的子元素触发 change 事件时,执行下面的位置函数:
$('#col_1').Sortable(
{
change: positions,
}
);
问题是“位置”向未通过的服务器发送 ajax 帖子:
function positions(){
**i've removed some javascript code leading to a javascript variable called "variable" ***
xmlhttp = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject('Microsoft.XMLHTTP');
xmlhttp.open('POST', '/positions.php', true);
xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
xmlhttp.send("epositions="+variable);
xmlhttp.send(null);
return true;
}
所以 Post 不会发送到服务器。但我注意到,如果我改为放置
$('#col_1').Sortable(
{
change: function() { positions(); },
}
);
点击 col_1 中子节点的句柄时会发送 ajax 帖子,但无法再对元素进行排序。有
change: function(data) { positions(); },
也不发送 ajax 请求,尽管元素已排序。
我该如何克服这个问题?是我做错了什么还是 UI 可排序的问题?
【问题讨论】:
标签: jquery ajax user-interface jquery-ui-sortable