类似YouTube的Ajax加载栏无效

时间:2014-03-23 00:07:51

标签: php jquery ajax youtube loading

我使用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而且我不确定为什么这不起作用。

1 个答案:

答案 0 :(得分:0)

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

是获得响应的地方,在此示例中,数据将等于“某些内容”,因此您可以使用响应,例如替换html页面的内容;​​

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