我有一个页面,我需要为某些元素添加拖放功能。当drop事件发生时,它会对ajax调用一个php函数,然后刷新div的内容。我使用jQuery和jQueryUI进行拖放操作,并将CakePHP作为PHP框架使用(不确定这是否相关)。Opera和Google Chrome中的jquery ajax问题
在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(在错误事件),它是“不确定”
你可以发布URL到这个页面或演示?这里没有足够的证据来解释为什么会发生这种情况。 – hallvors