Thread: ajax question
View Single Post
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>