select标记上的Ajax动画
Ajax animation on select tag
我正在AJAX调用中搜索视觉动画。但是我想要一个选择html标签上的动画,而不是整个页面上的动画。
这样做可能吗?
谢谢。
如果我要这样做,我会使用CSS创建一个助手类来显示和隐藏ajax加载程序(作为背景图像或图标(。然后,我会在ajax调用之前设置该类,然后在回调中删除它。
下面是我所说内容的演示(我将使用Font Awesome作为ajax加载程序(。
HTML
<button>Submit<i class="fa fa-circle-o-notch fa-spin"></i></button>
CSS
button{
position:relative;
padding:6px 32px;
border:0;
background:#42c827;
color:#fff;
}
button i{
position:absolute;
top:7px;
right:8px;
opacity:0;
}
button.busy i{
opacity:1;
}
JavaScript
$(function(){
$('button').on('click', function(e){
e.preventDefault();
var btn = $(this);
btn.addClass('busy');
//simulate ajax call
setTimeout(function(){
btn.removeClass('busy');
}, 2000);
});
});
在这个Fiddle中看到它的实际操作。
更新
对于<select>
标记,标记有点不同,但思想是相同的。相反,您将加载程序放在<select>
旁边,而不是放在它的内部,并为它们提供一个外部包装。
有关使用<select>
标签的演示,请参阅此Fiddle。
您可以使用jQuery ajaxStart
和ajaxStop
处理程序在AJAX过程中生成一些东西。
$( document ).ajaxStart(function() {
$(".preloader").show();
});
不在select标记内,但动画可以放在它附近。我做这样的动画。。..
这是js:
$(document).ready(function(){
$('#refresh').click(function(){
//show the animation here
$('#animation_place').html("<img src='loading_anim.gif'/>");
$.ajax({
//write your url and type and the othre things here..
success:function(data){
//Bind the select tag with the new data
$('#animation_place').html(""); //clear the animation..
}
});
});
});
相关文章:
- json-ajax动画防止通过php发送数据
- 如果 Ajax 请求太快,jQuery 动画将无法正常工作
- 当 ajax 请求速度时不显示动画.js
- 加载动画在第二次 ajax 调用之前消失
- 使动画函数在执行 $.ajax 调用时正常工作
- 刷新 AJAX 内容时保持 jquery 动画
- jQuery:链接动画和AJAX请求
- jQuery的组件不是彩色动画和ajax
- Jquery Prepend动画只适用于AJAX一次
- 使用Ajax和CSS3制作动画
- Ajax附加结果并设置动画
- 如何使用jQuery等待动画链和ajax调用的完成
- 在ajax jquery上可以看到一些动画
- 如何同时创建ajax请求和背景动画
- 引导模式ajax内容,动画加载
- 在Ajax响应后重新触发css3动画时出现问题
- ajax动画后,动画显示,但内容不显示
- 在AJAX请求期间显示等待动画
- select标记上的Ajax动画
- 拆分Ajax动画