Today's Posts Follow Us On Twitter! TFL Members on Twitter  
Forum search: Advanced Search  
Navigation
Marketplace
  Members Login:
Lost password?
  Forum Statistics:
Forum Members: 24,254
Total Threads: 80,792
Total Posts: 566,471
There are 595 users currently browsing (tf).
 
  Our Partners:
 
  TalkFreelance     Design and Development     Programming     Other Programming Languages :

ajax question

Thread title: ajax question
Closed Thread    
    Thread tools Search this thread Display Modes  
09-11-2007, 03:18 AM
#1
Village Genius is offline Village Genius
Village Genius's Avatar
Status: Geek
Join date: Apr 2006
Location: Denver, CO
Expertise: Software
Software: Chrome, Notepad++
 
Posts: 6,894
iTrader: 18 / 100%
 

Village Genius will become famous soon enough

  Old  ajax question

How do I get multi-line data from the Request.responseText element of th DOM? I have a basic ajax script where I need to return an entire page of data.

Here is the code
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head>
	<script src="javascripts/prototype.js" type="text/javascript"></script>
	<script src="javascripts/scriptaculous.js" type="text/javascript"></script>
	<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><title>Title Here</title>
</head>
<body>
<script language="javascript" type="text/javascript">
<!-- 
function reset(){
	new Effect.SwitchOff("result");
}
function GetRSS(){
	var Request;
	
	try{
		// Opera 8.0+, Firefox, Safari
		Request = new XMLHttpRequest();
	} 
	catch (err)
	{
		// Internet Explorer Browsers
		try
		{
			Request = new ActiveXObject("Msxml2.XMLHTTP");
		} 
		catch (err) 
		{
			try
			{
				Request = new ActiveXObject("Microsoft.XMLHTTP");
			} 
			catch (err)
			{
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	
	// Create a function that will receive data sent from the server
	Request.onreadystatechange = function(){
		
		if(Request.readyState == 4){
			document.getElementById("result").innerHTML = Request.responseText;
		}
		
	}
	Request.open('POST', "functions/rss.php", true);
	Request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	Request.send("url=http://www.youngbutstrong.com/feed" );
}

//-->
</script>


<a href="" onclick="GetRSS(); return false;">Click me</a>
<div id="result"  onclick="reset();">&nbsp;</p>
</body>
</html>

09-11-2007, 03:40 AM
#2
CreativeLogic is offline CreativeLogic
CreativeLogic's Avatar
Status: Request a custom title
Join date: Feb 2005
Location:
Expertise:
Software:
 
Posts: 1,078
iTrader: 6 / 100%
 

CreativeLogic is on a distinguished road

Send a message via MSN to CreativeLogic

  Old

Is it giving you any errors or anything like that? It should be working just fine from what I've quickly taken a look at.

09-11-2007, 03:42 AM
#3
Village Genius is offline Village Genius
Village Genius's Avatar
Status: Geek
Join date: Apr 2006
Location: Denver, CO
Expertise: Software
Software: Chrome, Notepad++
 
Posts: 6,894
iTrader: 18 / 100%
 

Village Genius will become famous soon enough

  Old

Originally Posted by CreativeLogic View Post
Is it giving you any errors or anything like that? It should be working just fine from what I've quickly taken a look at.
It returns text, but one line, I need everything that it returns
http://justanotherportfolio.com/rss/

09-11-2007, 10:22 AM
#4
Salathe is offline Salathe
Salathe's Avatar
Status: Community Archaeologist
Join date: Jul 2004
Location: Scotland
Expertise: Software Development
Software: vim, PHP
 
Posts: 3,820
iTrader: 25 / 100%
 

Salathe will become famous soon enough

Send a message via MSN to Salathe

  Old

The response from the AJAX call is:
HTML Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

<html lang="en">

<head>

	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

	<title>RSS Feeds Example</title>

	<style type="text/css">

	   li a { display: block; }

	   li span { color: #f90; font-size: 85%; }

	</style>

</head>

<body>

   <h1>RSS Feeds Example</h1>

	</body>

</html>
When that's inserted into the DOM, the html, head and body tags are removed leaving the h1 as the visible element. It looks like the "one line" that it returns is because the rss.php file isn't returning the feed items in the HTML.

09-11-2007, 01:31 PM
#5
Village Genius is offline Village Genius
Village Genius's Avatar
Status: Geek
Join date: Apr 2006
Location: Denver, CO
Expertise: Software
Software: Chrome, Notepad++
 
Posts: 6,894
iTrader: 18 / 100%
 

Village Genius will become famous soon enough

  Old

Fixed, thanks!

Closed Thread    


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

  Posting Rules  
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump:
 
  Contains New Posts Forum Contains New Posts   Contains No New Posts Forum Contains No New Posts   A Closed Forum Forum is Closed