简体   繁体   English

jQuery load()错误:不推荐使用主线程上的同步XMLHttpRequest

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

I am trying to load a page within another page using jquery load() function. 我正在尝试使用jquery load()函数在另一个页面中加载页面。 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. 当我单击按钮时,整个页面被清除,只显示“edit.php”页面的一个位。 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. 单个位我的意思是edit.php应该显示一个预先填充的表单,只显示一个没有CSS的单个字段。 Is it because I am using the wrong jQuery function ie load(). 是因为我使用了错误的jQuery函数,即load()。 What I want to do is load a new page in a div tag within the current page. 我想要做的是在当前页面的div标签中加载新页面。

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. jquery.min.js:4主线程上的同步XMLHttpRequest因其对最终用户体验的不利影响而被弃用。

Where am I going wrong? 我哪里错了?

You may get this warning in case edit.php contains a script tag within it that loads an external javascript file eg 如果edit.php中包含一个加载外部javascript文件的脚本标记,则可能会收到此警告

<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 请注意,这是来自这个stackoverflow的答案 - https://stackoverflow.com/a/28478146/3274227

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 jQuery加载正在触发主线程上的Synchronous XMLHttpRequest不建议警告 - jquery load is triggering Synchronous XMLHttpRequest on the main thread is deprecated warning 不赞成在主线程上使用同步XMLHttpRequest - Synchronous XMLHttpRequest on the main thread is deprecated 不推荐在主线程上使用同步XMLHttpRequest - Synchronous XMLHttpRequest on the main thread is deprecated XMLHTTPRequest错误:不建议在主线程上使用同步XMLHttpRequest…(SoundCloud API) - XMLHTTPRequest Error: Synchronous XMLHttpRequest on the main thread is deprecated … (SoundCloud API) WordPress + jQuery Mobile-不赞成在主线程上使用同步XMLHttpRequest吗? - WordPress + jQuery Mobile - Synchronous XMLHttpRequest on the main thread is deprecated? 使用jQuery加载外部javascript并禁止“不建议在主线程上使用同步XMLHttpRequest…” - Loading external javascript with jQuery and suppress “Synchronous XMLHttpRequest on the main thread is deprecated…” 我在加载javascript时遇到问题。 错误:不建议使用[不推荐使用]主线程上的同步XMLHttpRequest - I have a problem whit load to javascript. Error: [Deprecation] Synchronous XMLHttpRequest on the main thread is deprecated 向后移动会导致错误:““不赞成在主线程上使用同步XMLHttpRequest…” - moving backward causes error: "“Synchronous XMLHttpRequest on the main thread is deprecated…” 为什么不赞成在主线程上使用ajax调用给出Synchronous XMLHttpRequest错误? - Why ajax call give error of Synchronous XMLHttpRequest on the main thread is deprecated? 不推荐使用主线程上的Firebase同步XMLHttpRequest - Firebase Synchronous XMLHttpRequest on the main thread is deprecated
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM