jQuery load() error : Synchronous XMLHttpRequest on the main thread is deprecated

javascript, jquery

Solution

You may get this warning in case edit.php contains a script tag within it that loads an external javascript file e.g.

<div> 
SOME CONTENT HERE
</div>
<script src="/scripts/script.js"></script> 

Just to note that this is from this stackoverflow answer - https://stackoverflow.com/a/28478146/3274227

Problem

I am trying to load a page within another page using jquery load() function. Below is the code: ``` ... head code </head> <body id="body"> <div id="newbody"></div> <button id="loadit">loadpage</button> <script type="text/javascript"> $("#loadit").click(function(){ $( "#newbody" ).load( "edit.php?id=112" ); }); </script> ``` When I click the button the whole page is cleared and only a single bit of the "edit.php" page is displayed. By single bit I mean that edit.php is supposed to display a prepopulated form and only a single field is displayed with no CSS whatsoever. Is it because I am using the wrong jQuery function i.e. load(). What I want to do is load a new page in a div tag within the current page. I also get the following warning in the console: jquery.min.js:4 Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. Where am I going wrong?

Original source

Related problems