Hello folks, trying to submit a form I am getting ...
# suitecommerce
m
Hello folks, trying to submit a form I am getting a
Uncaught SyntaxError: Unexpected token < in JSON at position 0
error. Payload of the request looks good in that it is the correct form data. The info in the document of the response isn't proving helpful; it says:
An unexpected SuiteScript error has occurred
This is part of why I am posting this here. I've seen messages in there before like, "unterminated string" or whatever that have pointed me in the right direction to a typo or some error usually in the .ss file, but this isn't giving me much. This is a 2019.1 SCA site, btw. Thank you!! edit: also, some generic logs in the .ss file aren't even hitting, so I don't think it's making it there, but not sure why. In the front end Model, I am setting the url like so:
urlRoot: 'services/AuthorizedRegistration.Service.ss'
s
Two things come to mind: 1. If it's returning that error that means it's usually sending back an HTML document rather than JSON. I would inspect the HTML it is sending back and see if there an error message in the body of the document (eg permission error, 404, etc) 2. Quite often this is associated with incorrectly parsing or stringifying data. I would make sure that when your service receives the form data it is parsing it (or you are sending it as a string) for example.
if your service is set up only to handle POSTs then you can still add a GET handler to it and just ping it (eg with jQuery.ajax())on the frontend and make sure it is connecting correctly, for example
m
yeah, in the HTML doc it's sending back is where the
An unexpected SuiteScript error has occurred
is
s
Ah yes you said that. Well, I would strip out all the SuiteScript except the stuff required to handle the request and then add it back in and see where it starts going wrong