JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsWeb DesignJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old March 18th, 2009, 08:14 AM
redstar redstar is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jul 2003
Posts: 679 redstar User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Days 15 h 14 m 40 sec
Reputation Power: 10
Send a message via ICQ to redstar Send a message via AIM to redstar Send a message via MSN to redstar Send a message via Yahoo to redstar
Import html content with Javascript/Ajax

Hi,

I need to import a content from an url using JavaScipt or Ajax.

I need to import this:
http://example.com/menu.html

Into each page of the site. It need to be relative, because the site is on different machines. Also this need to copy the CSS/JS.

Can you please help me?

Reply With Quote
  #2  
Old March 18th, 2009, 10:05 AM
vbrtrmn's Avatar
vbrtrmn vbrtrmn is offline
4:04 Time Not Found
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Jan 2004
Location: Northern Virginia
Posts: 2,273 vbrtrmn User rank is Major (30000 - 40000 Reputation Level)vbrtrmn User rank is Major (30000 - 40000 Reputation Level)vbrtrmn User rank is Major (30000 - 40000 Reputation Level)vbrtrmn User rank is Major (30000 - 40000 Reputation Level)vbrtrmn User rank is Major (30000 - 40000 Reputation Level)vbrtrmn User rank is Major (30000 - 40000 Reputation Level)vbrtrmn User rank is Major (30000 - 40000 Reputation Level)vbrtrmn User rank is Major (30000 - 40000 Reputation Level)vbrtrmn User rank is Major (30000 - 40000 Reputation Level)vbrtrmn User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 22 h 10 m
Reputation Power: 337
Send a message via ICQ to vbrtrmn Send a message via AIM to vbrtrmn Send a message via MSN to vbrtrmn Send a message via Yahoo to vbrtrmn
So, you want to make a copy of some web site using javascript?!? Probably not trivial to do, I'd use wget or perl.
__________________
I am so smart, I am so smart, S.M.R.T ... I mean S.M.A.R.T.

Stop Using Pop-Ups

Reply With Quote
  #3  
Old March 18th, 2009, 01:27 PM
janusz-jasinski janusz-jasinski is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Oct 2004
Location: Birmingham, UK
Posts: 722 janusz-jasinski User rank is Sergeant Major (2000 - 5000 Reputation Level)janusz-jasinski User rank is Sergeant Major (2000 - 5000 Reputation Level)janusz-jasinski User rank is Sergeant Major (2000 - 5000 Reputation Level)janusz-jasinski User rank is Sergeant Major (2000 - 5000 Reputation Level)janusz-jasinski User rank is Sergeant Major (2000 - 5000 Reputation Level)janusz-jasinski User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 3 Days 20 h 7 m 31 sec
Reputation Power: 41
Send a message via MSN to janusz-jasinski
javascript Code:
Original - javascript Code
  1. <script src="http://code.jquery.com/jquery-latest.js"></script>
  2.  
  3. <script>
  4. var refreshId = setInterval(function()
  5. {
  6.      $('#responsecontainer').load('test.asp');
  7. }, 1000);
  8. </script>
then I use
Code:
<div id="responsecontainer">
</div>

Last edited by janusz-jasinski : March 18th, 2009 at 01:30 PM.

Reply With Quote
  #4  
Old March 18th, 2009, 02:41 PM
redstar redstar is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jul 2003
Posts: 679 redstar User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Days 15 h 14 m 40 sec
Reputation Power: 10
Send a message via ICQ to redstar Send a message via AIM to redstar Send a message via MSN to redstar Send a message via Yahoo to redstar
Can I use it just one time, not to refresh?

I need to copy from a page with absolute url? Can I do it?

Where do I find a list of functions of what can do Jquery on this?

Thanks.

Reply With Quote
  #5  
Old March 19th, 2009, 12:54 AM
redstar redstar is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jul 2003
Posts: 679 redstar User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Days 15 h 14 m 40 sec
Reputation Power: 10
Send a message via ICQ to redstar Send a message via AIM to redstar Send a message via MSN to redstar Send a message via Yahoo to redstar
No, it don't import me anything.

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html><head>
<meta content="text/html; charset=ISO-8859-1" http-equiv="content-type"><title>Test Import Header</title>

<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
var refreshId = setInterval(function()
{
$('#responsecontainer').load('http://example.com/TestTemplate/Header/index.htm');
}, 1000);
</script>
</head><body>

<br>
<div id="responsecontainer">
</div>

</body></html>

Reply With Quote
  #6  
Old March 19th, 2009, 01:24 AM
redstar redstar is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jul 2003
Posts: 679 redstar User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Days 15 h 14 m 40 sec
Reputation Power: 10
Send a message via ICQ to redstar Send a message via AIM to redstar Send a message via MSN to redstar Send a message via Yahoo to redstar
If I try this it works:

Code:
<html>
<head>
	<title>jQuery - Ajax dynamic content loading</title>
	<script src="jquery-latest.js" type="text/javascript"></script>
	<script type="text/javascript">
		function loadContent(id) {
			$("#contentArea").load("test.html");
		}
	</script>
</head>
<body onLoad="loadContent();">
	
	
	<div id="contentArea" style="margin: 20px 0px 10px 10px; border: 1px solid #CCC;">
		&nbsp;
	</div>
	
	

</body>
</html>


But I need to call it from another machine on the same domain.

Thank you!

Reply With Quote
  #7  
Old March 19th, 2009, 04:51 AM
redstar redstar is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jul 2003
Posts: 679 redstar User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Days 15 h 14 m 40 sec
Reputation Power: 10
Send a message via ICQ to redstar Send a message via AIM to redstar Send a message via MSN to redstar Send a message via Yahoo to redstar
I also try with $.ajax

Code:
<html>
<head>
	<title>jQuery - Ajax dynamic content loading</title>
	<script src="http://code.jquery.com/jquery-latest.js" type="text/javascript"></script>
	<script type="text/javascript">
		function loadContent(id) {
			$.ajax({
				url: "http://www.google.com",
				cache: false,
				success: function(html){
				$("#contentArea").append(html);
  }
});
		}
	</script>
</head>
<body onLoad="loadContent();">
	
	
	<div id="contentArea" style="margin: 20px 0px 10px 10px; border: 1px solid #CCC; width: 780px; height: 250px; float: left;">
		&nbsp;
	</div>
	
	

</body>
</html>

Reply With Quote
  #8  
Old December 27th, 2012, 07:19 PM
vimxts vimxts is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2012
Posts: 1 vimxts User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 m 43 sec
Reputation Power: 0
Can't you use a simpler way?

window.onload = function(){
$('#thisHtml'sElement').load('myHTML.html');
};

The script first check if the page finished loading, then execute the function and load a external url.

Hope it works

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignJavaScript Development > Import html content with Javascript/Ajax

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap