Jquery 在AJAX调用期间,在Chrome或任何浏览器中加载GIF图标时不显示动画
在AJAX调用期间,在Chrome或任何浏览器中加载GIF图标时不显示动画 我首先称之为功能:Jquery 在AJAX调用期间,在Chrome或任何浏览器中加载GIF图标时不显示动画,jquery,ajax,Jquery,Ajax,在AJAX调用期间,在Chrome或任何浏览器中加载GIF图标时不显示动画 我首先称之为功能: function Row(x) { var threadID = x.parentNode.id; var urlForActionComments = $("#GettingCommentsJSON").val(); var listOfComments; $('#overLapContainer').append('<img id="loadingImage" src="../Res
function Row(x) {
var threadID = x.parentNode.id;
var urlForActionComments = $("#GettingCommentsJSON").val();
var listOfComments;
$('#overLapContainer').append('<img id="loadingImage" src="../Resources/IMAGES/LoadingImage.gif" />');
$('#overLapContainer').show();
$.ajax({
type: 'POST',
url: urlForActionComments,
dataType: 'JSON',
data: { threadID: threadID },
success:function(data)
{
//$('#replyContentDiv').css('display', 'block');
listOfComments = data;
setTimeout(appendingComments(listOfComments),100);
//appendingComments(listOfComments);
},
error: function () {
alert('Error While Fetching Likes for'+threadID)
}
})
}
function appendingComments(listOfComments)
{
for (var i = 0; i < listOfComments.length; i++) {
var userMailID = listOfComments[i].CreatedByEmail;
var newContent = imageForComment(userMailID);
commentRow = '<div class="commentNewContainer">\
<div class="leftCommentNewContainer">\
<input type="hidden" class="' + userMailID + '" />\
<img id="' + i + '" src="#" />\
</div>\
<div class="rightCommentNewContainer"><span>' + listOfComments[i].CommentContent + '</span></div>\
</div>';
$('#commentContainerID').append(commentRow);
var forMailid = '.leftCommentNewContainer' + ' ' + '#' + i;
if (newContent != null) {
$(forMailid).attr("src", "data:image/png;base64," + newContent);
}
else
{
$(forMailid).attr("src", "/Resources/IMAGES/default_user.png");
}
}
}
在调用appendingComments函数之前,我正在加载gif图标。我正在调用imageForComment()函数。但是GIF图像没有按照我的需要加载。您需要添加有关您正在使用的html的更多详细信息。请添加其余代码。我们看到的只是一篇Ajax文章,其中隐藏了几个
div
。您还缺少2个分号代码>。一个在警报
行之后,一个在最末尾。我调用这个AJAX函数n次。在AJAX调用之前,我要使GIF图标可见。但它不是加载/设置动画。它只是显示为静态的.jpg。ajax调用后,gif通常隐藏为,请提供使gif可见的代码。HTML和jsp都更新了代码。HTML和JS都有
function imageForComment(userMailID) {
var urlForFetchingImage = $('#FetchingPostUserImageviaEMailJSON').val();
var image = null;
setTimeout(
$.ajax({
type: 'POST',
url: urlForFetchingImage,
dataType: 'JSON',
async: false,
data: { email: userMailID },
success: function (data) {
//$('#replyContentDiv').css('display', 'block');
////debugger;
image = data.ImageBytesAsString;
//var idforImage = '#' + userMailID;
//if (data.ImageBytesAsString != null) {
// $(idforImage).attr("src", "data:image/png;base64," + data.ImageBytesAsString);
//}
//else {
// $(idforImage).attr("src", "/Resources/IMAGES/default_user.png");
//}
},
error: function (ex) {
alert(ex);
}
}), 100);
return image;
}