我有一个页面,我需要在其中向某些元素添加拖放功能。当 drop 事件发生时,它对 php 函数进行 ajax 调用,然后刷新 div 的内容。我使用 jQuery 和 jQueryUI 进行拖放,并使用 CakePHP 作为 PHP 框架(不确定这是否相关)。
在 Firefox、Safari 甚至 IE 中一切正常,但在 Opera 或 Chrome 中,div 的内容没有刷新(尽管 PHP 函数的操作已执行)。
所以,这里是代码:
jQuery('#lists div').
filter(function() {return this.id.match(/item[\d]+_[\d]+/);}).
each(function() { jQuery(this).draggable( {axis: 'y'}); });
jQuery('#lists div').
filter(function() {
return this.id.match(/list[\d]+/);}).
each(function() {
jQuery(this).droppable({
drop: function(event, ui) {
dropID = jQuery(event.target).attr('id');
dragID = jQuery(ui.draggable).attr('id');
itemID = dragID.substr(dragID.lastIndexOf('_') + 1);
oldListID = dragID.substr(4).replace(/_[\d]+/g, '');
newListID = drop.substr(4);
jQuery.ajax({
url: "/lists/itemToList/"+itemID+"/"+oldListID+
"/"+newListID,
type: "POST",
success: function (data) {
jQuery('#lists').html(data);}
});
}
});
});
基本上,没有执行成功函数,但是如果我尝试查看 errorThrown (在错误事件上)它是“未定义的”