bootstrap-validator
bootstrap-validator copied to clipboard
How to display remote response message?
On my form I'm using:
data-remote="./ajax/checkEmail.php"
In my "checkEmail.php" file I'm returning this...
if ($num) {
http_response_code(400);
echo("Email Address is already in use.");
} else {
http_response_code(200);
}
The Chrome Console shows the 400 error (looks like a JQuery error), but the response message isn't displayed in the "help-block with-errors" div. Am I doing something wrong?
I got the same issue.
Request URL: https://localhost:44301/business/Feedback/VerifyUrl?ClosingButton2Url=http%3A%2F%2Fwww.bbc.com%2Fnews Request Method: GET Status Code: 400 Remote Address: [::1]:44301 Referrer Policy: no-referrer-when-downgrade
access-control-allow-credentials: true access-control-allow-origin: www... cache-control: private content-length: 4717 content-type: text/html; charset=utf-8 date: Wed, 18 Apr 2018 15:29:59 GMT server: Microsoft-IIS/10.0 status: 400 x-aspnet-version: 4.0.30319 x-aspnetmvc-version: 5.2 x-powered-by: ASP.NET x-sourcefiles: =?UTF-8?B?QzpcVEZTXERldlxTb3VyY2VcTGVhcGNoYXQuV2ViXGJ1c2luZXNzXEZlZWRiYWNrXFZlcmlmeVVybA==?=
Hi,
I think it's too late for you but if my suggestion can help someone
Change this line (line 219 on validator.js)
.fail(function (jqXHR, textStatus, error) { errors.push(getErrorMessage('remote') || error) })
to
.fail(function (jqXHR, textStatus, error) { errors.push(getErrorMessage('remote') || jqXHR.responseText) })
With this php response on error case :
http_response_code(400); echo 'Response Message';
Now in your "help-block with-errors" you can show your message.
Thank you a lot, it helped me to solve this issue : nothing is never too late !