1

I have an HTML page generated by an objective-C application and I want to load and open it in a local directory (not in a web server). The javascripts jquery.js and jquery.plot.js are stored in the same directory before the page is loaded. I made the HTML page by following closely the examples available on http://flot.googlecode.com/ The scripts are declared in the HTML page as follows :

<script src="jquery.js" language="javascript" type="text/javascript"></script>
<script src="jquery.flot.pack.js" language="javascript" type="text/javascript"></script>

When I open the page, the expected graph (generated by the scripts) doesn't show up and I have the following syntax error in the javascript console :

Uncaught SyntaxError: Unexpected token ILLEGAL 

The script source in the javascript console is made of strange (chinese ?) ideograms which are obviously "unexpected token" if it is what the browser sees. I have the same problem with Chrome, Firefox and Safari. The problem is not systematic because sometimes, it works !. I have made tests with files prepared manually and again it works sometimes only. I have also copied the same file which didn't work in another directory where the jquery scripts were present and, surprise, it worked ! but not always... I have exhausted all my ideas on this problem and your help will be very much appreciated

T.J. Crowder
  • 1,031,962
  • 187
  • 1,923
  • 1,875
philippehenri
  • 167
  • 2
  • 9
  • You need to wrap any code in your post or else it won't show correctly. – Ryan Feb 20 '12 at 14:45
  • 3
    This is your sixth question, you really should be marking things up correctly by now. When you were typing your question, to the right there was a **How to Format** box. Well worth a read, as are the various bits of information available via the **[?]** button above the text area. There's also a preview area underneath so you can see how your question will look when it's posted, and of course an "edit" link once you post the question if, on re-reading it (and you did bother, right?) you see that some of the formatting didn't work. Bothering with all this shows respect for other people's time. – T.J. Crowder Feb 20 '12 at 14:49
  • 1
    Did you propose this edit to add new information? If you log in your can just edit your question which makes much more sense. – Felix Kling Feb 20 '12 at 18:40
  • I'm having the exact same problem. Did you ever find a fix? – Salem Nov 28 '12 at 05:37
  • Salem, try using `//cdnjs.cloudflare.com/ajax/libs/flot/0.7/jquery.flot.min.js` as your `src=` attribute. – Ross Rogers Nov 29 '12 at 02:09

2 Answers2

1

Did you copy the JavaScript from an external source? I know I have had problems when copying from JSFiddle for example. Try removing any whitespace and see if that will get rid of the illegal token error.

Ryan
  • 2,433
  • 5
  • 31
  • 41
  • The zipped flot library comes from http://code.google.com/p/flot/downloads. I do not see any whitespaces I could remove – philippehenri Feb 20 '12 at 15:23
0

I just had this problem and it was because the server on which my javascript was being hosted wasn't configured to send the javascript file with the correct MIME type. See this question.

Instead of fixing my server, I just opted to use a CDN path from cdnjs.com:

//cdnjs.cloudflare.com/ajax/libs/flot/0.7/jquery.flot.min.js
Community
  • 1
  • 1
Ross Rogers
  • 23,523
  • 27
  • 108
  • 164