jquery在没有被告知的情况下启动了
我想在5000秒后发射get_Conva,但在我点击一条消息后它会自动发射jquery在没有被告知的情况下启动了,jquery,Jquery,我想在5000秒后发射get_Conva,但在我点击一条消息后它会自动发射 $(".mes").click(function(){ var user = $(this).attr("id"); $("#convo").html(user); $(".convo_mes").html("Loading conversation <img width='15' height='15' src='./img/load.gif'>");
$(".mes").click(function(){
var user = $(this).attr("id");
$("#convo").html(user);
$(".convo_mes").html("Loading conversation <img width='15' height='15' src='./img/load.gif'>");
setTimeout(get_convo(user),5000);
});
//get convo
function get_convo(user){
$.post("./php/get_convo.php",{username:user},function(get_convo){
$(".convo_mes").html(get_convo);
});
}
$(“.mes”)。单击(函数(){
var user=$(this.attr(“id”);
$(“#conva”).html(用户);
$(“.conva_mes”).html(“加载对话”);
设置超时(获取车队(用户),5000);
});
//抓住护卫队
函数get_conva(用户){
$.post(“./php/get_-conva.php”,{username:user},函数(get_-conva){
$(“.conva_mes”).html(get_conva);
});
}
函数读取setTimeout函数后将立即调用该函数。你必须给出一个适当的函数。这样setTimeout可以稍后调用该函数。这将是解决方案:
$(".mes").click(function(){
var user = $(this).attr("id");
$("#convo").html(user);
$(".convo_mes").html("Loading conversation <img width='15' height='15' src='./img/load.gif'>");
setTimeout(function(){ get_convo(user)},5000);
});
$(“.mes”)。单击(函数(){
var user=$(this.attr(“id”);
$(“#conva”).html(用户);
$(“.conva_mes”).html(“加载对话”);
setTimeout(函数(){get_conva(用户)},5000);
});
函数读取setTimeout函数后将立即调用该函数。你必须给出一个适当的函数。这样setTimeout可以稍后调用该函数。这将是解决方案:
$(".mes").click(function(){
var user = $(this).attr("id");
$("#convo").html(user);
$(".convo_mes").html("Loading conversation <img width='15' height='15' src='./img/load.gif'>");
setTimeout(function(){ get_convo(user)},5000);
});
$(“.mes”)。单击(函数(){
var user=$(this.attr(“id”);
$(“#conva”).html(用户);
$(“.conva_mes”).html(“加载对话”);
setTimeout(函数(){get_conva(用户)},5000);
});
如果这不起作用,那么可能只是因为AJAX做了它想做的事情
如果这不起作用,那么可能只是因为AJAX做了它想做的。成功了,非常感谢!非常感谢!