Synchronous XMLHttpRequest warning and – Perttu May 08 '17 at 12:23

7

Even the latest jQuery has that line, so you have these options:

  • Change the source of jQuery yourself - but maybe there is a good reason for its usage
  • Live with the warning, please note that this option is deprecated and not obsolete.
  • Change your code, so it does not use this function

I think number 2 is the most sensible course of action in this case.

By the way if you haven't already tried, try this out: $.ajaxSetup({async:true});, but I don't think it will work.

meskobalazs
  • 15,741
  • 2
  • 40
  • 63
  • It won't, as `_evalUrl` specifies `async` setting explicitly. – raina77ow Feb 04 '15 at 13:44
  • True, however if, for some reason, jquery loads ` – eithed Feb 04 '15 at 13:45
5

I was plagued by this error message despite using async: true. It turns out the actual problem was using the success method. I changed this to done and warning is gone.

success: function(response) { ... }

replaced with:

done: function(response) { ... }

Tim Hallman
  • 854
  • 15
  • 27
5

if you just need to load script dont do as bellow

$(document.body).html('<script type="text/javascript" src="/json.js" async="async"><\/script>');

Try this

var scriptEl = document.createElement('SCRIPT');
    scriptEl.src = "/module/script/form?_t="+(new Date()).getTime();
    //$('#holder').append(scriptEl) // <--- create warning
    document.body.appendChild(scriptEl);
surinder singh
  • 1,463
  • 13
  • 12
  • 1
    This effectively disables caching of JS scripts - however, if you'll remove the `getTime()` bit, then yes, it will work (as it won't use jQuery and won't be parsed, thus not going into bugged bit) – eithed Mar 15 '16 at 12:50
2

In my case this was caused by the flexie script which was part of the "CDNJS Selections" app offered by Cloudflare.

According to Cloudflare "This app is being deprecated in March 2015". I turned it off and the message disappeared instantly.

You can access the apps by visiting https://www.cloudflare.com/a/cloudflare-apps/yourdomain.com

Arnaud
  • 17,268
  • 9
  • 65
  • 83
0

In my case if i append script tag like this :

var script = document.createElement('script');
script.src = 'url/test.js';
$('head').append($(script));

i get that warning but if i append script tag to head first then change src warning gone !

var script = document.createElement('script');
$('head').append($(script));
script.src = 'url/test.js';

works fine!!

Mr.Sun
  • 129
  • 4