[英]jquery .ajax's .done function get done on alert only
This seems a bit strange and i cant get a hold of the situation, apparently i used jquery's .ajax() function to process some script to get some data from the database. 这似乎有点奇怪,我无法掌握这种情况,显然我使用了jquery的.ajax()函数来处理一些脚本以从数据库中获取一些数据。 The script works fine and data gets returned as accordingly:
该脚本可以正常工作,并相应地返回数据:
$.ajax({
type: "POST",
url: "getevaluationdata.php",
data: { evaluation_ID: value }
})
.done(function( msg ) {
$("#error2").html(msg);
});
After the scripts process, it is suppose to populate the data echoed in the script to the div i mentioned, but this does not happen. 在脚本处理之后,假定将脚本中回显的数据填充到我提到的div,但这不会发生。 However, if i write an alert statement before the div population, the div gets populated.
但是,如果我在div填充之前写了一个警告语句,则div将被填充。 meaning:
含义:
$.ajax({
type: "POST",
url: "getevaluationdata.php",
data: { evaluation_ID: value }
})
.done(function( msg ) {
alert(msg);
$("#error2").html(msg);
});
I dont seem to get why this is happening and what I can do to resolve this. 我似乎不明白为什么会这样,我该怎么办才能解决这个问题。 PS I have done this before, and this was working correctly before
PS我之前已经做过,并且在此之前可以正常工作
Is it possible #error2 is not on the page yet?, so the alert gives it time? 页面上可能还没有#error2吗?因此警报会给它时间吗? try putting the ajax call in
尝试将ajax调用放入
$(function(){
$.ajax({
type: "POST",
url: "getevaluationdata.php",
data: { evaluation_ID: value }
}).done(function( msg ){
$("#error2").html(msg);
});
});
Another thing you can try for reference is using the success callback 您可以尝试参考的另一件事是使用成功回调
$.post("getevaluationdata.php",{evaluation_ID:value},function(msg){
$("#error2").html(msg);
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.