Chrome: Uncaught SyntaxError: Unexpected end of input

visibility 31 access_time 10 months ago languageEnglish timeline Stats
timeline Stats
Page index 0.11

When developing web applications, I encounter the following error:

Uncaught SyntaxError: Unexpected end of input

The cause of this error can vary and I will share one of the 'stupid' error I made and the resolution.

The culprit

The following line of code actually caused the error in my scenario:

<a href="#" class="ms-1" onclick="reply("comment_uxbohdkpue",1033,"Ray","ReplyToCommentId");">Reply</a>

To fix the error, we just need to change the double quotes in the function to single quote:

<a href="#" class="ms-1" onclick="reply('comment_uxbohdkpue',1033,'Ray','ReplyToCommentId');">Reply</a>

Other causes

There can be many other causes. One of the common cause can be missing closing bracket '}' in your JavaScript code. To debug the code, it can be time-consuming and I would recommend using elimination strategy to comment/uncomment function code to find the culprit. 


copyright This page is subject to Site terms.

Please log in or register to comment.

account_circle Log in person_add Register

Log in with external accounts

More from Kontext
jQuery Unobtrusive Validation with Bootstrap 5 CSS
visibility 821
thumb_up 0
access_time 9 months ago
jQuery Unobtrusive Validation with Bootstrap 5 CSS
Download Google Fonts via Gulp
visibility 443
thumb_up 0
access_time 2 years ago
Trigger Event after All Images Loaded
visibility 173
thumb_up 0
access_time 8 months ago