Problems with Xmlhttprequest Angularjs

Asked

Viewed 530 times

0

I have a $http.get request in my application as seen on Angularjs ng-repeat does not return data, always returns empty

However I am receiving a Warning in the browser console with the following message:

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

How can I solve?

  • What code causes this Warning? This is being displayed by Chrome recently when you try to run the method open of an Xmlhttprequest with the third parameter as false, which prevents the request from being asynchronous.

  • Guilhermenagatomo, here is my code: http://answall.com/questions/57324/angularjs-ng-repeat-n%C3%A3o-returns-data-returns-always-empty. And yes, it’s being displayed on Crhome the moment you access the view that accesses the data

  • Which version of Angular you’re using?

  • version 1.3.14 CDN Google

  • Looking fast through the source of the Angular, it doesn’t seem that the problem is in it. Is there any other code that uses ajax outside the Angular? Warning does not indicate in the console the line where it is activated?

  • Does not indicate anything, just the message and makes a reference to jquery. Is it some incompatibility?

  • @Jacsondanerm.Brandão Add to your question the relevant areas of your code and. This Warning is usually caused by jQuery, so add here also the relevant areas of your code that make use of it.

Show 2 more comments

1 answer

1

Possible causes:

  • If your request returns $http.get have a mention to a javascript file, jQuery (as well as other libraries) will try to load the mentioned file in synchronous mode (since it assumes that you need the JS file to interpret the content being transmitted.
  • If your request (which in practice translates as an Xmlhttprequest request) is running on thread main and without the flag indicating an asynchronous operation - for example, $.ajax() with async: false.

Solutions: Make your request on a thread separate, or use the flag async: true in jQuery.

This message is native to the browser. jQuery, by implementing synchronous load, can trigger the warning.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.