Web Connection
SyntaxError: Unexpected token < in JSON at position 0
Gravatar is a globally recognized avatar based on your email address. SyntaxError: Unexpected token < in JSON at position 0
  Joe Baisa
  All
  Dec 24, 2019 @ 09:41am

Hello All,

I am getting an error from code that used to work.

"SyntaxError: Unexpected token < in JSON at position 0"

I am using the standard method jsonCallBack()

Debugger shows the lcJSON variable has the string value of:

"{"dsdstatus":"0","errormsg":"null"}"

I'm suspecting that Chrome is receiving an HTML string.

Any insight on what's causing this would be greatly appreciated.

Thanks. Joe

Gravatar is a globally recognized avatar based on your email address. re: SyntaxError: Unexpected token < in JSON at position 0
  Rick Strahl
  Joe Baisa
  Dec 24, 2019 @ 01:50pm

There was likely an error in your processing of the request. The response returned is HTML so the Web Connection error handler probably got triggered when processing failed. You should step through the code on the server and see what fails. My guess is you're never getting to returning your JSON data.

FWIW this is easier with the wwRestProcess class which handles the error handling and wraps up all errors into JSON exception messages.

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: SyntaxError: Unexpected token < in JSON at position 0
  Joe Baisa
  Rick Strahl
  Dec 27, 2019 @ 09:23am

Rick,

Thanks for the quick response. A more thorough look at the code showed that a very minor change cause a call to method that calls "Response.ExpandScript(....)". Easily resolved.

Thanks, Joe

© 1996-2020