Today, while I was working with jQuery I ran on this error Uncaught SyntaxError: Unexpected end of input while troubleshooting my code in Chrome. And since Chrome it didn’t report error on any specific line I had to Google for it 🙂
And after opening few pages I found out that this error codes happens when you forget closing “}”. That can happen often when writing JavaScript code.
Locating that is not easy, especially if you’r code is sloppy and you have a lot of it. Luckily my code is always very nicely written so I got it solved quickly. But in case your code is really messy or is compressed (with some JavaScript compressing tool like jscompress.com) you can copy/paste your JavaScript code into jsbeautifier.org, click on Beautify JavaScript (select the options you want on the right side of the screen first) and see if all of the indentations are correct.
Beautiful and Geeky.
Can't download new apps to your phone because there isn't enough storage space? Lack of…
This issue started to appear on macOS 13 Ventura after recent Dropbox update. I would…
Since this morning (Feb 5th 2020) search just stopped working on my Windows 10 (version…
Many of you have run into a problem when you were working on some old…
After 10 years of running my main desktop computer on Windows 7 - time has…
I installed VestaCP for a clien on a new dedicated server running CentOS 7. Once…
View Comments
That was exactly it, thanks man!
This is not the case always, what if you are getting this error after few clicks on your document.
I just got this error and all my braces were perfect. In fact, all my code was ... erm.. "perfect".
For me the problem turned out to be improperly formed JSON data I was getting from the server. For some reason the data was truncated (thus naturally missing a few closing braces) and it blew up in JSON.parse() - which kind of makes it seem like JSON.parse is using eval() which I thought it shouldn't, but Chrome seemed to be giving me this error at the top of the function in which the JSON.parse() was being called. It was very perplexing until I took a look at what data was coming across the wire.
If you are getting EMPTY JSON response from server and using JQuery version higher than 1.9 then JSON.Parse will throw this SyntaxError. This is happening due to JSON.PARSE functionality.
Refer http://api.jquery.com/jquery.parsejson/
I had similar issue too but it wasn't related to the the brackets. It was to do with parsing an empty json. Most of the google results spoke about brackets however I finally got the solution on https://www.moreonfew.com/uncaught-syntaxerror-unexpected-end-of-input-resolved/ . Hope anyone seeing this comment in future find the solution too.
you're a life saviour thanks man <3