Jump to content

"Uncaught SyntaxError: Unexpected end of input" Chrome error


Go to solution Solved by LLLLLLL,

Recommended Posts

I'm getting "Uncaught SyntaxError: Unexpected end of input" (VM4193:1) on this AJAX call:

  MakeRequest : function( blah, blah ) {
    $.post( blah-blah-url,
      function( data ) {

      var result = null;
      try {							
      	result = JSON.parse( data );
      } catch (err) {


      SOMETHING.HandleResult( result );
    .fail( function() {


... the odd thing is, I get this error in Chrome before anything has actually happened in the result. What I mean is: when I put the breakpoint on result=null, the error happens right there. The parse() function has no error, so... what on earth is going on?


I'm not sure how to be any more clear on this or what to add. It's quite standard stuff. The JSON blob that's returned is obviously valid... so I wonder where that error is coming from?

Link to comment
Share on other sites

So have you looked at the stack trace for the error yet?


But the JSON blob can be parsed, so it's not an invalid blob.

Says who? Where is the proof it was parsed correctly? You can't know because execution hasn't even gotten to that point.


Besides that, nothing has interacted with "data" at this point, so where would an error come from?

From jQuery recognizing the response as JSON and trying to decode it automatically.
Link to comment
Share on other sites

You're contradicting yourself.


1. According to you,

Yes, I put a breakpoint there -- which means BEFORE that line has executed -- and the error already occurred.

the JSON has not been parsed yet at the time of the error.


2. Also according to you,

It gets parsed on the next line of code without issue.

it is a proper JSON object because it has been parsed, which would have happened before the error.


You can't have both. So pick:

a) The JSON is valid because the line of code that parses the JSON magically executed without you seeing it, or

b) The JSON may or may not be valid; you cannot tell because the line of code that parses the JSON has not magically executed without you seeing it

Link to comment
Share on other sites

  • Solution

I'm tired of PHP Freaks. Too many people trying to show their arrogance and not help.


As I have stated, the error is before any parsing. The parsing is always successfu. The error occurs immediately when DATA has a value.  You're the only one mentioning magic. Nothing magic is happening.


I'm done with this thread. Getting no help and never will.

Link to comment
Share on other sites

I'm tired of PHP Freaks.


Then go away. Your schtick of posting nonsense and then complaining about those who actually know what they're doing may have been funny for a while. But after 7 years, it's a rather lame routine.


Spend less time bitching and more time programming. Then you might actually get somewhere.

Link to comment
Share on other sites

This thread is more than a year old.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.