简体   繁体   中英

jquery.js call from HTML syntax error

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

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM