Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Aug 2008
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Appending external html page to div with jQuery causes refresh

    Hi, im trying to append an external html page on the same domain into a div.
    The html page has this javascript in it that prints out two names:

    Namnsdag : <script language="Javascript" src="http://www.startsidan.org/namnsdag.php"></script>

    But in firefox the pages refreshes and gets bugged, in IE only the text before javascript tags shows up in the div.

    Im using this jQuery code

    Code:
    $.ajax({
      url: "test.html",
      cache: false,
      success: function(html){
        $("#div1").append(html);
      }
    });
    So my question is, how can i load the external page into the div correct?

    I have also set up a test page to show this error: http://cior.se/bugg/index.html

    Thanks.

  • #2
    Regular Coder
    Join Date
    Feb 2009
    Location
    Wheeling, IL
    Posts
    358
    Thanks
    5
    Thanked 62 Times in 60 Posts
    If you're simply loading a JS file and executing it... try the following:

    http://docs.jquery.com/Ajax/jQuery.getScript

    Additionally, script language="javascript" is deprecated and obsolete, use script type="text/javascript" instead.

    As to why your function replaces the entire web-page.... it seems that the contents are:

    Code:
    function visanamndag() {
    document.write ("Ingemar och Gudmar"); 
    } visanamndag();
    You do know document.write after a page has done loading does achieve that result, right?
    Last edited by Eldarrion; 06-03-2009 at 06:11 AM.
    The way to success is to assume that there are no impossible things. After all, if you think something is impossible, you will not even try to do it.

    How to ask smart questions?

  • #3
    New to the CF scene
    Join Date
    Aug 2008
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks for the answer. Well, the page reloading bug, i should have knew about that, but i didint . Thanks for telling me.

    I guess i can solve my problem by loading the page in a iframe instead. But then the height will be bugged.


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •