JavaScript console.log causes error: “Synchronous XMLHttpRequest on the main thread is deprecated…”

后端 未结 21 1706
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-11-22 09:26

I have been adding logs to the console to check the status of different variables without using the Firefox debugger.

However, in many places in which I add a

相关标签:
21条回答
  • 2020-11-22 09:54

    I was also facing same issue but able to fix it by putting async: true. I know it is by default true but it works when I write it explicitly

    $.ajax({
       async: true,   // this will solve the problem
       type: "POST",
       url: "/Page/Method",
       contentType: "application/json",
       data: JSON.stringify({ ParameterName: paramValue }),
    });
    
    0 讨论(0)
  • 2020-11-22 09:54

    @Webgr partial answer actually helped me debug this warning @ console log, shame the other part of that answer brought so many downvotes :(

    Anyway, here is how I found out what was the cause of this warning in my case:

    1. Use Chrome Browser > Hit F12 to bring DevTools
    2. Open the drawer menu (in Chrome 3 vertical dots in the upper right)
    3. Under Console > check Log XMLHttpRequests option
    4. Reload your page that was giving you the error and observe what happens on each ajax request in the console log.

    In my case, another plugin was loading 2 .js libraries after each ajax call, that were absolutely not required nor necessary. Disabling the rogue plugin removed the warning from the log. From that point, you can either try to fix the problem yourself (e.g. limit the loading of the scripts to certain pages or events - this is way too specific for an answer here) or contact 3rd party plugin developer to solve it.

    Hope this helps someone.

    0 讨论(0)
  • 2020-11-22 09:54

    In a MVC application, I got this warning because I was opening a Kendo Window with a method that was returning a View(), instead of a PartialView(). The View() was trying to retrive again all the scripts of the page.

    0 讨论(0)
提交回复
热议问题