Oh, so you want to fetch text from a page and use it? The string being returned from the page should be properly formatted for JS too, as I believe they use the same escape sequences.
If you want to look at debugging info on Firefox you can go to the Firefox menu > web developer > web console, then reload the page and it should give you some hints as to what is going wrong.
The easiest way I know to do an AJAX request, again is using jQuery's get function: http://api.jquery.com/jQuery.get/ This does things in the best way for whatever browser it is running on.
Try pointing the URL to the same page that generates it as a test, when I did that, things worked just fine under Firefox. Remember that Cross Domain requests are not allowed in AJAX or any Javascript for that matter due to security concerns (i.e. scripts from www.google.com can't connect to www.yahoo.com ). Some older versions of IE may allow this, and/or may allow it if you just open it up from your desktop as that really isn't a domain.
This is the way it worked on Firefox/Chrome for me:
<html>
<head>
<script type='text/javascript'>
var request;
var itemId=1;
try{
request = new XMLHttpRequest();
} catch(e) {
try {
request = new ActiveXObject("Microsoft.XMLHTTP");
} catch(e) {
alert("Error creating XMLHttpRequest \n" + e);
}
}
request.open("GET", "file:///home/joseph/Desktop/js.html", true);
request.onreadystatechange = function(){
if (request.readyState == 4 ){
alert(request.responseText);
}
};
request.send(); // The null isn't strictly necessary here as any params left out are automatically null
</script>
</head>
<body>
<h1>hello world</h1>
</body>
</html>
- Joe