开发者

Load and unload a page into a div from a page already loaded in

开发者 https://www.devze.com 2023-02-16 00:11 出处:网络
Im using this code: <!--Page Loading Mechanism--> <script type=\"text/javascript\"> $( document ).ready( function() {

Im using this code:

<!--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>

to load in external pages using a navigation menu in the parent page. Ok, now it loads the pages fine when i click on the nav buttons.

Now, what im trying to do is load another external page into this same div from a button on the child page. Im trying to basically overwrite the child with thew page. I thought a regular < a href> would do the trick, but it does nothing but opens the new page into the main window, replacing the parent page. I dont want that.

How do I replace the first child page, with the new external page, but into the same div the child was already loaded, replacing it. What code would I write on the first loaded child page?

I pray you all are not confused reading this, as this is t开发者_C百科he best way i could explain it.


See if this works for you, of course if using ajax is OK..

$.ajax({url:"url",
        success : onSuccess
});

function onSuccess(result){
$("#<id of div to be updated>").html(result);
}
0

精彩评论

暂无评论...
验证码 换一张
取 消