gpt4 book ai didi

javascript - 为什么 ajax beforeSend 在函数成功后继续运行?

转载 作者:行者123 更新时间:2023-11-29 21:49:00 26 4
gpt4 key购买 nike

调用 ajax 函数没有问题,但是 beforeSend 图像继续运行。我做错了什么?

$tag_link_list = $('#tag_link_list');
current_page = '1';
click_term = '1';
var data = {
action: 'click_symptom',
postSearchNonce: MyAjaxSearch.postSearchNonce,
click_term: click_term,
p: current_page

};
$.ajax({
url: MyAjaxSearch.ajaxurl,
type: 'POST',
cache: false,
data: data,
beforeSend: function() {
$tag_link_list.html('<i id="tag_entry_spinner" class="fa fa-spinner fa-pulse fa-5x"></i>');

},
success: function(data) {
if (data) {
$tag_link_list.append(data);
current_page++
} else {
$('#messages_list').html('<center>No result to show.</center>');
}
}
}); //ajax

最佳答案

尝试:

success: function(data) {
if(data) {
$tag_link_list.html(data);
current_page++
} else {
$tag_link_list.empty();
$('#messages_list').html('<center>No result to show.</center>');
}
}

关于javascript - 为什么 ajax beforeSend 在函数成功后继续运行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30110293/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com