Javascript Can';t在不重新加载页面的情况下重新加载ajax

Javascript Can';t在不重新加载页面的情况下重新加载ajax,javascript,jquery,ajax,Javascript,Jquery,Ajax,我只希望它“重新加载”到#searchuserc。我搜索了这么多信息,但我不能解决这个问题 $(文档).ready(函数(){ $(“#onlineusers”).load(“online.php”); $(“#searchuserc”).show(); setInterval(函数(){ $(“#onlineusers”).load(“online.php”); }, 5000); $(“.search”)。单击(函数(){ $(“#onlineusers”).hide(); e、 preve

我只希望它“重新加载”到
#searchuserc
。我搜索了这么多信息,但我不能解决这个问题

$(文档).ready(函数(){
$(“#onlineusers”).load(“online.php”);
$(“#searchuserc”).show();
setInterval(函数(){
$(“#onlineusers”).load(“online.php”);
}, 5000);
$(“.search”)。单击(函数(){
$(“#onlineusers”).hide();
e、 preventDefault();//防止默认提交
$.ajax({
url:'searchuser.php',
键入:“POST”,
数据:$(this).serialize(),//它将序列化表单数据
数据类型:“html”
})
.完成(功能(数据){
$('searchuserc').fadeOut('slow',function(){
$('searchuserc').fadeIn('slow').html(数据);
});
})
.fail(函数(){
警报('Ajax提交失败…');
});
});
});
这是我的HTML文件


而不是

$(".search").click(function() {
  ...
使用

处理程序中的代码可以保持不变。

而不是

$(".search").click(function() {
  ...
使用

处理程序中的代码可以保持不变。

如果调用e.preventDefault(),但不定义e,请检查js控制台是否有错误,我认为您需要$(“.search”)。单击(函数(e){$(this)。序列化()-单击的按钮?可能更改$('#searchuserc')。淡出('slow',function(){$('searchuserc')。淡出('slow')。淡出('searchuserc')。淡出('slow')).html(data);})
$('#searchuserc').fadeOut('slow',function(){$(this).html(data);}).fadeIn('slow');
如果调用e.preventDefault(),但不定义e,请检查js控制台中的错误,我认为您需要$(“.search”)。单击(function(e){
$(this).serialize())
-单击的按钮?可能会将
$('#searchuserc').fadeOut('slow',function(){$('#searchuserc').fadeIn('slow').html(data);})更改为
$('#searchuserc').fadeOut('slow',function(){$(this.html(data)}.fadeIn('slow');