I am using the YouTube-like Ajax Loading Bar to load a php file.

This is my 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) {}
});

This is my HTML

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

This is load.php, the file that I'm trying to load

<?php
echo 'some content';
?>

I'm haven't used ajax before and I'm not sure why this isn't working.

有帮助吗?

解决方案

On

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

is where you get the response, in this example, data will be equal to "some content", so there you can work with the response, for example replace the content of your html page;

success: function (data) {
    $('body').html(data);
}
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top