Jump to content

"Uncaught SyntaxError: Unexpected end of input" Chrome error


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,
      obj,
      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

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

:psychic:

 

The JSON is not valid, and the error happens is because jQuery parsed it for you automatically. The exception backtrace would have told you as much, if you had bothered to look at it when I told you to 7 hours ago.

 

But whatever. Your code, your problem.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.