【问题标题】:YouTube-like Ajax Loading Bar not working类似 YouTube 的 Ajax 加载栏不起作用
【发布时间】:2014-04-30 09:21:48
【问题描述】:

我正在使用YouTube-like Ajax Loading Bar 加载一个 php 文件。

这是我的 Javascript

$(".ajax-call").loadingbar({
  target: "#loadingbar-frame",
  replaceURL: false,
  direction: "right",
  async: true, 
  complete: function(xhr, text) {},
  cache: true,
  error: function(xhr, text, e) {},
  global: true,
  headers: {},
  statusCode: {},
  success: function(data, text, xhr) {},
  dataType: "html",
  done: function(data) {}
});

这是我的 HTML

<a href="load.php" class="ajax-call">..</a>
<div id="loadingbar-frame"></div>

这是 load.php,我正在尝试加载的文件

<?php
echo 'some content';
?>

我以前没有使用过 ajax,我不确定为什么这不起作用。

【问题讨论】:

    标签: php jquery ajax youtube loading


    【解决方案1】:

    开启

    success: function(data, text, xhr) {},
    

    是你得到响应的地方,在这个例子中,数据将等于“一些内容”,所以你可以在那里处理响应,例如替换你的 html 页面的内容;

    success: function (data) {
        $('body').html(data);
    }
    

    【讨论】:

    • 谢谢,效果很好!有没有办法可以使用 POST 将数据发送到 php 文件?
    猜你喜欢
    • 2013-10-10
    • 2012-05-15
    • 2015-03-16
    • 2023-03-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多