I have a script that calls an ajax function to display the contents of a text file.
Everything seems to work fine with the display, but I am getting error in the error console.
They say:
[code]
not well-formed ImMyOwnGrandpa.txt:1
syntax error LegendInMyTime.txt:1
There are no errors referencing the script and the normal independently created text files appear fine also.
My questions are:
1. Where do I look to find the meaning of the error messages in the error console of the FF browser?
2. Any ideas as to what or where to look to not get the non-fatal error messages?
This is the code (abbreviated) I’m using when the errors occur.
I do not include the text files, but they can be referenced to a live link, if needed.
[code]
<!DOCTYPE html>
<html lang=”en”>
<head>
<meta charset=”UTF-8″ />
<meta name=”viewport” content=”width=device-width”>
<meta name=”viewport” content=”initial-scale=1.0, user-scalable=yes”/>
<title> Song Lyrics </title>
<style type=”text/css”>
@media screen, print { body { line-height: 1.2 } }
#song { width:100%; height:100%; }
#menu div { width:250px; float:left; background-color:#ffffcc; }
#menu div:hover { background-color:orange; }
</style>
</head>
<body>
<div id=”menu”></div>
<hr style=”clear:both”>
<pre id=”song”></pre>
<hr>
Good site for
Country:
<br><a href=”http://www.classic-country-song-lyrics.com/”>http://www.classic-country-song-lyrics.com/</a>
<br>Bluegrass: <a href=”http://www.classic-country-song-lyrics.com/bluegrasslyricschords.html”>http://www.classic-country-song-lyrics.com/bluegrasslyricschords.html</a>
<br>
<script type=”text/javascript”>
function $_(IDS) { return document.getElementById(IDS); }
// Modified from: http://www.w3schools.com/ajax/ajax_serverscript.asp
function ajaxFunction(filename,storeTo) {
var xmlHttp;
try { xmlHttp=new XMLHttpRequest(); } // Firefox, Opera 8.0+, Safari
catch (e) { // Internet Explorer
try { xmlHttp=new ActiveXObject(“Msxml2.XMLHTTP”); }
catch (e) {
try { xmlHttp=new ActiveXObject(“Microsoft.XMLHTTP”); }
catch (e) { alert(“Your browser does not support AJAX!”); return false; }
}
}
xmlHttp.onreadystatechange=function() {
var CurrentReadyState = xmlHttp.readyState;
if (CurrentReadyState==4) {
// document.getElementById(storeTo).value=xmlHttp.responseText;
document.getElementById(storeTo).innerHTML=xmlHttp.responseText.replace(/\n/g,'<br>’);
}
}
xmlHttp.open(“GET”,filename,true);
xmlHttp.send(null);
}
(function() {
var songList = [
“I’m My Own Grandpa|ImMyOwnGrandpa.txt”,
“Funny How Time Slips Away|FunnyHowTimeSlipsAway.txt”,
];
var str = ”, tmp = ”;
songList.sort();
for (var i=0; i<songList.length; i++) {
tmp = songList[i].split(‘|’);
str += ‘<div>’+tmp[0]+'</div>’;
}
$_(‘menu’).innerHTML = str;
var sel = $_(‘menu’).getElementsByTagName(‘div’);
for (var i=0; i<sel.length; i++) {
sel[i].info = i;
sel[i].onclick = function () { showSong(this.info); }
}
function showSong(info) {
var tarr = songList[info].split(‘|’);
ajaxFunction(tarr[1],’song’);
}
})();
</script>
</body>
</html>