4

Strange error here: I have a page that's referencing several JavaScript files. Occasionally, the browser will complain of:

Uncaught SyntaxError: Unexpected end of input

However, it doesn't appear to be due to a missing parent, or malformed JSON. Part of the JavaScript file will load, but the program will just stop loading the rest of the file. Example: half of the file will load, with the other half missing.

Most of the time, the files load and everything works. Any idea why I would occasionally be getting this error, rather than every time (as expected with a missing paren or something similar)? Other things I can check?


EDIT:

  • This is a Rails project (Rails version 3.2).
  • The JS files are standalone, and are kept in the pub directory for dev. In other words, they are NOT included in the asset pipeline.
10
  • 1
    Could you post the source? It'd make it easier to diagnose. Are the js files ajax or not? And have you run the files through jslint/jshint? Commented Jun 15, 2014 at 4:58
  • 1
    Got a live link? Otherwise run your code through jshint Commented Jun 15, 2014 at 4:58
  • 4
    This error is most likely due to missing a }. Can you please post the code. Commented Jun 15, 2014 at 5:00
  • 1
    @WayneEllery I'll try and get some source posted, in the meantime: have you seen this error occur only occasionally when caused by a missing }? Wouldn't it break on every load? Commented Jun 15, 2014 at 5:53
  • 1
    If you are using ajax with json it could be failing sometimes due to parsing invalid json. Commented Jun 15, 2014 at 5:58

1 Answer 1

-2

There must be braces not closed properly.The file stops loading whenever the error is encountered and leaves the rest part unloaded as because of error. You can check this example here

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.