Home > Mobile >  javascript .bind() is Not working on microsoft edge and Google chrome
javascript .bind() is Not working on microsoft edge and Google chrome

Time:08-16

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.

CodePudding user response:

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();
  });

});

CodePudding user response:

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();
  });

});
  • Related