Php 要显示ajax加载gif吗
我正在使用数据表。我的所有代码都运行良好。现在我想把ajax放在gif上。有人能帮我把ajax加载器放在gif上吗?这是我的密码。谢谢Php 要显示ajax加载gif吗,php,jquery,ajax,Php,Jquery,Ajax,我正在使用数据表。我的所有代码都运行良好。现在我想把ajax放在gif上。有人能帮我把ajax加载器放在gif上吗?这是我的密码。谢谢 <script type="text/javascript" charset="utf-8"> $(document).ready(function() { $("#dvloader").show(); oTable = $('#example').dataTable({
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
$("#dvloader").show();
oTable = $('#example').dataTable({
"bJQueryUI": true,
"sPaginationType": "full_numbers"
});
} );
(document).ready(function() {
$("#btnround").click(function(){
$.ajax({
url: "ajax_request.php",
cache: false,
async: true,
data: "shape=ROUND",
success: function(html){
$(".demo_jui").html(html);
}
});
});
});
</script>
$(文档).ready(函数(){
$(“#dvloader”).show();
oTable=$(“#示例”).dataTable({
“bJQueryUI”:没错,
“sPaginationType”:“完整编号”
});
} );
(文档).就绪(函数(){
$(“#btnround”)。单击(函数(){
$.ajax({
url:“ajax_request.php”,
cache:false,
async:true,
数据:“形状=圆形”,
成功:函数(html){
$(“.demo_jui”).html(html);
}
});
});
});
这应该很容易:
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
$("#dvloader").show();
oTable = $('#example').dataTable({
"bJQueryUI": true,
"sPaginationType": "full_numbers"
});
} );
(document).ready(function() {
$("#btnround").click(function(){
$(".demo_jui").html('<img src="path/to/loading.gif" />');
$.ajax({
url: "ajax_request.php",
cache: false,
async: true,
data: "shape=ROUND",
success: function(html){
$(".demo_jui").html(html);
}
});
});
});
</script>
$(文档).ready(函数(){
$(“#dvloader”).show();
oTable=$(“#示例”).dataTable({
“bJQueryUI”:没错,
“sPaginationType”:“完整编号”
});
} );
(文档).就绪(函数(){
$(“#btnround”)。单击(函数(){
$(“.demo_jui”).html(“”);
$.ajax({
url:“ajax_request.php”,
cache:false,
async:true,
数据:“形状=圆形”,
成功:函数(html){
$(“.demo_jui”).html(html);
}
});
});
});
这应该很容易:
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
$("#dvloader").show();
oTable = $('#example').dataTable({
"bJQueryUI": true,
"sPaginationType": "full_numbers"
});
} );
(document).ready(function() {
$("#btnround").click(function(){
$(".demo_jui").html('<img src="path/to/loading.gif" />');
$.ajax({
url: "ajax_request.php",
cache: false,
async: true,
data: "shape=ROUND",
success: function(html){
$(".demo_jui").html(html);
}
});
});
});
</script>
$(文档).ready(函数(){
$(“#dvloader”).show();
oTable=$(“#示例”).dataTable({
“bJQueryUI”:没错,
“sPaginationType”:“完整编号”
});
} );
(文档).就绪(函数(){
$(“#btnround”)。单击(函数(){
$(“.demo_jui”).html(“”);
$.ajax({
url:“ajax_request.php”,
cache:false,
async:true,
数据:“形状=圆形”,
成功:函数(html){
$(“.demo_jui”).html(html);
}
});
});
});
使用
ajaxStart()
及
ajaxComplete()
显示和隐藏加载gif的函数
$("#loading").ajaxStart(function(){
$(this).show();
});
$("#loading").ajaxComplete(function(){
$(this).hide();
});
而id为的div或元素
装载
已加载gif
$("#loading").ajaxStart(function(){
$(this).show();
});
$("#loading").ajaxComplete(function(){
$(this).hide();
});
您的最终代码应该如下所示:
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
$("#dvloader").show();
oTable = $('#example').dataTable({
"bJQueryUI": true,
"sPaginationType": "full_numbers"
});
});
(document).ready(function() {
$("#btnround").click(function() {
$.ajax({
url: "ajax_request.php",
cache: false,
async: true,
data: "shape=ROUND",
success: function(html) {
$(".demo_jui").html(html);
}
});
});
$("#loading").ajaxStart(function(){
$(this).show();
});
$("#loading").ajaxComplete(function(){
$(this).hide();
});
});
</script>
$(文档).ready(函数(){
$(“#dvloader”).show();
oTable=$(“#示例”).dataTable({
“bJQueryUI”:没错,
“sPaginationType”:“完整编号”
});
});
(文档).就绪(函数(){
$(“#btnround”)。单击(函数(){
$.ajax({
url:“ajax_request.php”,
cache:false,
async:true,
数据:“形状=圆形”,
成功:函数(html){
$(“.demo_jui”).html(html);
}
});
});
$(“#加载”).ajaxStart(函数(){
$(this.show();
});
$(“#加载”).ajaxComplete(函数(){
$(this.hide();
});
});
使用
ajaxStart()
及
ajaxComplete()
显示和隐藏加载gif的函数
$("#loading").ajaxStart(function(){
$(this).show();
});
$("#loading").ajaxComplete(function(){
$(this).hide();
});
而id为的div或元素
装载
已加载gif
$("#loading").ajaxStart(function(){
$(this).show();
});
$("#loading").ajaxComplete(function(){
$(this).hide();
});
您的最终代码应该如下所示:
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
$("#dvloader").show();
oTable = $('#example').dataTable({
"bJQueryUI": true,
"sPaginationType": "full_numbers"
});
});
(document).ready(function() {
$("#btnround").click(function() {
$.ajax({
url: "ajax_request.php",
cache: false,
async: true,
data: "shape=ROUND",
success: function(html) {
$(".demo_jui").html(html);
}
});
});
$("#loading").ajaxStart(function(){
$(this).show();
});
$("#loading").ajaxComplete(function(){
$(this).hide();
});
});
</script>
$(文档).ready(函数(){
$(“#dvloader”).show();
oTable=$(“#示例”).dataTable({
“bJQueryUI”:没错,
“sPaginationType”:“完整编号”
});
});
(文档).就绪(函数(){
$(“#btnround”)。单击(函数(){
$.ajax({
url:“ajax_request.php”,
cache:false,
async:true,
数据:“形状=圆形”,
成功:函数(html){
$(“.demo_jui”).html(html);
}
});
});
$(“#加载”).ajaxStart(函数(){
$(this.show();
});
$(“#加载”).ajaxComplete(函数(){
$(this.hide();
});
});
希望这对您有所帮助。添加beforeSend和complete属性并调用相应的函数
$("#btnround").click(function(){
$.ajax({
url: "ajax_request.php",
cache: false,
async: true,
data: "shape=ROUND",
beforeSend : fnLoadStart,
complete : fnLoadStop,
success: function(html){
$(".demo_jui").html(html);
}
});
});
function fnLoadStart() {
$("#dvloader").show(); // this div should have loader gif
}
function fnLoadStop() {
$("#dvloader").hide();
}
希望这对你有帮助。添加beforeSend和complete属性并调用相应的函数
$("#btnround").click(function(){
$.ajax({
url: "ajax_request.php",
cache: false,
async: true,
data: "shape=ROUND",
beforeSend : fnLoadStart,
complete : fnLoadStop,
success: function(html){
$(".demo_jui").html(html);
}
});
});
function fnLoadStart() {
$("#dvloader").show(); // this div should have loader gif
}
function fnLoadStop() {
$("#dvloader").hide();
}