views:

47

answers:

3

This may seem familiar, but I can't find anything about it...sure I've found stuff about "Unexpected Token Illegal," but these circumstances don't relate enough for those solutions to make sense.

I have my background page, like so:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Background Page</title>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="background.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
</head>
<body>

</body>
</html>

A small piece of w3-compliant markup, yet this is where the error "Unexpected Token ILLEGAL" occurs, on line 1. If I add a blank line at the top, it still throws an error at line one.

In my Javascript, I call three initialization functions:

localData.init();
localRead.init();
getTitles();

If I comment all three of these functions (no fewer), the error goes away. I've triple checked the rest of my code, and can see nothing wrong, syntactically or logically.

I am completely stumped...I've been programming in Javascript for years, and yet it still finds oddities to throw at me.

A: 

I often get this error when I've included a file that does not exist. Have you checked that jquery.js and background.js are indeed present?

ErikPerik
Yes, they are very present.
CMC
A: 

I figured out what it was: I was using the localStorage functionality, and had originally used my update function to initialize it, though once the update function required it to be previously defined, this error occurred...in the end, it seems I was passing null to JSON.parse, which somehow fails.

CMC
A: 

What does JSLint say if you run your code over it?

Dominic Mitchell