0

So I'm setting up a system for a small workplace, and I'm trying to run a live search on keyup that pulls a table of users. Each row has another button that can run a separate Ajax search for that specific user's clock in hours. How can I avoid or fix this deprecated issue?

I've tried using the .load() and the jQuery.ajax() functions on both data pulls, specifically tried the jQuery.ajax() to turn off async hoping that would work, but nothing has worked so far. The exact error states: "Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience."

For the people thinking this is a duplicate, the only other situation some asks for the same help on this site is when they were using the console.log() function, this problem is directly from PHP data pulling.

1st load :


$("#liveSearch").keyup(function(){
  var str = $(this).val();
  url: "manage/search.php?searchBy=ID&material="+str,
  success: function (result) {
    $("#searchResult).html(result);
  }
});

2nd load :


function callUser(user, period, week){
  jQuery.ajax({
    url : "manage/print.php?id="+user+"&p="+period+"&week"+week,
    success: function(result) {
      $("#result").html(result);
    }
  });
}

All that I need is for the information to both be pulled while keeping the PHP queries in tact.

  • Possible duplicate of [JavaScript console.log causes error: "Synchronous XMLHttpRequest on the main thread is deprecated..."](https://stackoverflow.com/questions/24639335/javascript-console-log-causes-error-synchronous-xmlhttprequest-on-the-main-thr) – aynber Oct 31 '19 at 15:37
  • Not a duplicate, that user is having the same issue but with overuse of the console.log() function – Gregory Pope Oct 31 '19 at 15:38
  • It could be if the `result` contains script tags, as mentioned in one of the answers. However, there's not quite enough information here to verify that. – aynber Oct 31 '19 at 15:40
  • they both work fine on there own though – Gregory Pope Oct 31 '19 at 15:42

1 Answers1

0

This notice is from the jQuery.com website

Deprecation Notice: The jqXHR.success(), jqXHR.error(), and jqXHR.complete() callbacks are removed as of jQuery 3.0. You can use jqXHR.done(), jqXHR.fail(), and jqXHR.always() instead.

replace success with done. you can read more about it here

Ram Segev
  • 2,563
  • 2
  • 12
  • 24
  • thanks, although it would only work if i changed the second one to done by itself but i understand how that works now – Gregory Pope Oct 31 '19 at 15:47
  • 1
    Note that the `success` property of the `$.ajax` settings object and `jqXHR.success()` are not the same thing. The former is fine, the latter is deprecated – Rory McCrossan Oct 31 '19 at 15:48