...

View Full Version : jQuery Appending external html page to div with jQuery causes refresh



d0ri0
06-03-2009, 12:00 AM
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



$.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.

Eldarrion
06-03-2009, 05:05 AM
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:



function visanamndag() {
document.write ("Ingemar och Gudmar");
} visanamndag();


You do know document.write after a page has done loading does achieve that result, right?

d0ri0
06-03-2009, 03:32 PM
Thanks for the answer. Well, the page reloading bug, i should have knew about that, but i didint :p. 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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum