我正在尝试更改AJAX代码以添加一个小的更改效果,这样用户就可以看到屏幕上发生了一些事情,因为内容的更改是隐藏的,很难注意到只有一些数字发生了更改
function changeBox(post) {
if (http != null) {
http.open("POST", 'ajaxchangebox.php', true);
http.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
http.onreadystatechange = function() {
if (!http) {
return;
}
if (http.readyState == 4) {
document.getElementById("box").innerHTML = http.responseText;;
}
}
http.send(post);
}
}
我不熟悉Javascript/AJAX。效果本身并不重要。它应该是一些闪光的东西,颜色的短暂变化或类似的东西。
感谢你的帮助克里斯蒂安
发布于 2016-08-08 16:57:27
也许这能帮上忙:Animate.css
用法:
document.getElementById("box").classList.add('bounce animated')您需要添加一个监听器来捕获动画结束事件:
var onDone = (function(){
var elm = document.getElementById('box');
var animateEndName = function () {
var i,
el = document.createElement('div'),
mapping = {
'animation': 'animationend',
'OAnimation': 'oanimationend',
'MozAnimation': 'animationend',
'WebkitAnimation': 'webkitAnimationEnd'
}
for (i in mapping) {
if (el.style[i] !== undefined) {
return mapping[i];
}
}
}();
elm.addEventListener(animateEndName, function(){
elm.classList.remove('flash', 'animated');
});
return function(result){
elm.innerHTML = result;
elm.classList.add('flash', 'animated');
}
})();https://stackoverflow.com/questions/38824559
复制相似问题