0

This code is working perfectly on mozila(103.0) but, it is not working on chrome or microsoft edge.

$('#loading').bind('ajaxStart', function () {
  $(this).show();
}).bind('ajaxStop', function () {
  $(this).hide();
});

on console it gives Notice :

Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user’s experience.

8
  • 3
    1) You have a missing ' in the seelctor of your first jQuery object 2) What version of jQuery are you using? bind() was deprecated a long time ago. Update jQuery and use on() instead. Aug 16, 2022 at 9:19
  • I am using jquery-1.8.3 Aug 16, 2022 at 9:36
  • Update to 3.6 and try that Aug 16, 2022 at 9:38
  • 1
    api.jquery.com/ajaxstart - as of 1.9 global ajax events must be attached to document - so for 1.8.3 it might be ok, but for 3.6 will need some changes.
    – freedomn-m
    Aug 16, 2022 at 10:03
  • Any Idea on this notice ? > "Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user’s experience" Aug 16, 2022 at 10:27

2 Answers 2

0

As .bind() method is deprecated. You can use .on() method instead.

$(document).ready(function(){

  $('#loading').on('ajaxStart', function () {
    $(this).show();
  }).bind('ajaxStop', function () {
    $(this).hide();
  });

});
-1

I would say that you might forgot to wait for document being ready:


$(document).ready(function(){

  $('#loading').bind('ajaxStart', function () {
    $(this).show();
  }).bind('ajaxStop', function () {
    $(this).hide();
  });

});
1
  • This is working only for the mozila. Aug 16, 2022 at 9:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.