Benjamin W Benjamin W - 4 years ago 223
Ajax Question

jQuery load (ajax) file content external script got error XMLHttpRequest is deprecated

//A.php
<script type="text/javascript">
$(document).ready(function(e) {
$('div').load("B.php");
});
</script>

<div></div>

//B.php
<script type="text/javascript" src="B.js"></script>

//B.js
console.log(123);


I have a console error

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


when I use jquery ajax load another page content external script links

Anyone know how to fix this?

Answer Source

The script on the other page has set the third parameter of the .open() method of the XMLHttpRequest to false, which makes a synchronous request instead of an asynchronous one. If you have access to the the script, you can set the value to true as long as it doesn't affect the sequence of the scripts rendering. This might also be set inside of a number of jQuery AJAX functions. Check the async property for a boolean (true / false); it would be set to false for this error.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download