admin管理员组文章数量:1323714
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?
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?
Share Improve this question edited Oct 26, 2016 at 16:47 Arihant asked Oct 26, 2016 at 16:45 ArihantArihant 4,04718 gold badges59 silver badges91 bronze badges 5- Are you getting any errors at all, either in your console, or on the actual edit.php page? – MCMXCII Commented Oct 26, 2016 at 16:47
- @MCMXCII just edited with the warning in console. edit.php, as a separate page works totally fine – Arihant Commented Oct 26, 2016 at 16:48
- Have you tried using the .ajax() function instead of .load()? – MCMXCII Commented Oct 26, 2016 at 16:50
-
2
@sabithpocker, it's
async: false
actually. But it looks like it's only a warning and not the root cause of the problem. – Frédéric Hamidi Commented Oct 26, 2016 at 16:51 - @sabithpocker - I think the data is being called but the whole page is being changed. any thoughts on that? – Arihant Commented Oct 26, 2016 at 17:00
1 Answer
Reset to default 8You 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./a/28478146/3274227
版权声明:本文标题:javascript - jQuery load() error : Synchronous XMLHttpRequest on the main thread is deprecated - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742128551a2422054.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论