In cloudpages, I've been trying to build a handler page for an ajax form POST that checks a certain DE to prevent duplicate submissions. It needs to return "duplicate entry, not saved" or "successfully saved" etc
I am aware that SSJS can set response headers, but it doesn't look like it can set status codes. Thus every request comes back with status: 200 even if the body of the response contains error information.
I have tried using a JSON code resource type, but I can't get SSJS to modify anything "lower level" than response headers.
How exactly can I return a "form post fail: duplicate entry exists" status code to my Jquery ajax form submit page?