Loading gif image while jQuery ajax is running

后端 未结 4 988
北海茫月
北海茫月 2020-12-08 11:57

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         


        
4条回答
  •  [愿得一人]
    2020-12-08 12:25

    I had a similar problem. To resolve my issue, I replaced the .text, in the beforeSend section, with .html and created a html tag to insert into the element that holds my status. The success function did not replaced the content created by the .text() function but it did replace content created by the .html() function.

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

提交回复
热议问题