# Simple Ajax Woes

**URL:** <https://forum.kirupa.com/t/simple-ajax-woes/240367>\
**Category:** web dev\
**Created:** [October 2, 2007, 1:36pm UTC](https://forum.kirupa.com/t/simple-ajax-woes/240367 "2007-10-02T13:36:04Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![javadi82](https://avatars.discourse-cdn.com/v4/letter/j/3be4f8/32.png) [@javadi82](https://forum.kirupa.com/u/javadi82)\
**Post date:** [October 2, 2007, 1:36pm UTC](https://forum.kirupa.com/t/simple-ajax-woes/240367/1 "2007-10-02T13:36:04Z")

</div>

Hi,

My first attempt at AJAX. Try to read an XML (RSS File) and populate a text-area.

Almost taken verbatium from this tutorial: [http://www.kirupa.com/developer/php/ajax\_intro.htm](http://www.kirupa.com/developer/php/ajax_intro.htm)

The html file below is on my local machine and it retrieves an RSS feed when the user clicks a button. But the text area does not seem to get populated… ☹

From the examples, I have seen on the forum, the URL must also be on the same domain? Otherwise, I am lost.

Thanks!

\<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN”  
“[http://www.w3.org/TR/html4/loose.dtd](http://www.w3.org/TR/html4/loose.dtd)”\>  
\<html\>  
\<head\>  
\<title\>Untitled Document\</title\>  
\<meta http-equiv=“Content-Type” content=“text/html; charset=iso-8859-1”\>  
\<script language=“javascript” type=“text/javascript”\>  
var xmlHttp;  
function createRequest() {  
if(window.ActiveXObject){  
xmlHttp = new ActiveXObject(“Microsoft.XMLHTTP”);  
}  
else if(window.XMLHttpRequest){  
xmlHttp = new XMLHttpRequest();  
}  
}  
function ajax() {  
createRequest();  
var url = “[http://newsrss.bbc.co.uk/rss/newsonline\_world\_edition/front\_page/rss.xml](http://newsrss.bbc.co.uk/rss/newsonline_world_edition/front_page/rss.xml)”;  
xmlHttp.open(“GET”, url, true);  
xmlHttp.onreadystatechange = StateChange;  
xmlHttp.send(null);  
}  
function StateChange(){  
if(xmlHttp.readyState == 4) {  
alert(xmlHttp.responseXML);  
var response = xmlHttp.responseText;  
document.getElementById(“reply”).innerHTML = response;  
}  
}  
\</script\>  
\</head\>  
\<body\>  
\<textarea rows=“20” cols=“40” name=“reply”\>\</textarea\>  
\<input type=“button” onClick=“ajax();” value=“Click here to AJAX it up”\>  
\<te\>  
\</body\>  
\</html\>
