0

I am getting this warning (Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience) while sending request through ajax. Jquery is working fine but this warning causing a performance issue in my website.

Jquery Code

$.ajax({

    url: "www.testproject.com/doubt-solving", 
    type: 'POST',
    success: function(result){
    $('#my-content-div').css('text-align','none');            
    $("#my-content-div").html(result.html);
}});
Axel Amthor
  • 10,980
  • 1
  • 25
  • 44
afzylive
  • 21
  • 5
  • 1
    Are you setting globally all ajax requests to synchronous mode or what? Is adding option `async: true,` or `global: false,` fixing your issue? Maybe your issue comes from content you are adding from `result.html`, see e.g: http://stackoverflow.com/questions/28322636/synchronous-xmlhttprequest-warning-and-script/28323156#28323156 – A. Wolff Oct 01 '15 at 08:09
  • Are you really sure it is the *warning* that's causing the performance issue ("this warning causing a performance issue") or would you consider that it might be the fact that you're using Synchronous XMLHttpRequests (intentionally or not / directly or not)? The warning is there *because* Synchronous XMLHttpRequests can cause performance issues. – freedomn-m Oct 01 '15 at 08:38
  • This has solved my bbig problem $.ajaxPrefilter(function( options, originalOptions, jqXHR ) { options.async = true; }); – afzylive Oct 01 '15 at 09:49

0 Answers0