本文介绍了而jQuery的AJAX运行时加载GIF图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我想显示加载图像,而我的Ajax调用运行,然而,使用 beforeSend 属性没有改变我的结果区域。

I am trying to show a loading image while my ajax call is running, however using the beforeSend attribute is not changing my result area.

$.ajax({
  url: "/answer_checker.php",
  global: false, type: "POST",
  data: ({...clipped...}),
  cache: false,
  beforeSend: function() {
    $('#response').text('Loading...');
  },
  success: function(html) {
    $('#response').html(html);
  }
}

在此先感谢。

Thanks in advance.

推荐答案

我有一个解决方案,它可能无法做到这一点的最好办法,但它在这种情况下工作。

I have a solution, it may not be the best way to do it but it has worked in this case.

$('input').keyup(function () {

  $('#response').text('loading...');

  $.ajax({
    url: "/answer_checker.php",
    global: false, type: "POST",
    data: ({...clipped...}),
    cache: false,
    success: function(html) {
      $('#response').html(html);
    }
  });
});

通过调用Ajax的功能,但它仍然显示,直到Ajax调用更新相同内容的加载文本之前设置resonce内容。

By setting the resonce content before calling the ajax function it remains showing the loading text until the ajax call updates the same content.

谢谢大家谁花时间来回答。

Thanks to everyone who took the time to answer.

阿伦

这篇关于而jQuery的AJAX运行时加载GIF图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 14:16