/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] Fixing errors un-related to script

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
[/code]

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>

[/code]

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@JMRKERauthorNov 10.2014 — Found the problem.

I was using ajax to load a local directory.

Placing script in server directory reports no problems upon file access.
×

Success!

Help @JMRKER spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 4.29,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...