我正在使用此代码:
<!--Page Loading Mechanism-->
<script type="text/javascript">
$( document ).ready( function() {
$( 'a.dynamicLoad' ).click( function( e ) {
e.preventDefault(); // prevent the browser from following the link
e.stopPropagation(); // prevent the browser from following the link
$( '#MainWrapper' ).load( $( this ).attr( 'href' ) , function() {
/* Content is now loaded */
});
});
});
</script>
使用父页面中的导航菜单加载外部页面。好的,现在它点击导航按钮时加载页面很好。
现在,我想要做的是从子页面上的按钮将另一个外部页面加载到同一个div中。我试图用w页面基本上覆盖孩子。我认为常规的< a href>
可以解决这个问题,但它只会将新页面打开到主窗口,替换父页面。我不想那样。
如何使用新的外部页面替换第一个子页面,但是将子项加载到同一个div中,替换它。我会在第一个加载的子页面上编写什么代码?
我祈祷你们都不会因此而感到困惑,因为这是我解释它的最佳方式。
答案 0 :(得分:0)
看看这是否适合你,当然如果使用ajax就行了。
$.ajax({url:"url",
success : onSuccess
});
function onSuccess(result){
$("#<id of div to be updated>").html(result);
}