This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center。
6年前关闭。
我有一个ajax函数,我希望它在完成后执行一些代码。我已经知道了,但是没有用。警报不会弹出。
6年前关闭。
我有一个ajax函数,我希望它在完成后执行一些代码。我已经知道了,但是没有用。警报不会弹出。
$.ajax({
type: "get",
url: "http://www.sinansamet.nl/chatdistract/ajax/getRooms.php",
success: function(html) {
$("#"+id+" ul").append(html);
$("#"+id+" ul").listview("refresh");
}
}).done(function(){
alert("Hello");
});
最佳答案
正如@karthikr在他的评论中所说,同时使用success:
和.done()
毫无意义,因为它们执行相同的工作。但是在成功连接后,它们都应同时运行。就是说...
您的问题可能是因为您正在访问另一个域,该域永远不会解析,因此也不会触发.done()
。
尝试将.done()
更改为.always()
,以解决连接成功还是失败的问题。