How could the following code sometimes evaluate to false?
(transport.responseText == '1' || transport.responseText == 'CARD_VALID')
My code is as follows:
if (transport.responseText == '1' || transport.responseText == 'CARD_VALID') {
// do something....
}
else if (transport.responseText == 'CARD_INVALID' || transport.responseText == 'INVALID_CHECKSUM') {
// do something else....
}
else {
new Ajax.Request('/report_error.php?responseText='+transport.responseText);
// report error to user
}
This is in the middle of an Ajax call and generally works, but sometimes (about once a day) it turns out that users will have what appears to be a response "CARD_VALID" in our logs, but will claim they received an error. I have started logging the response they received and the log files (made by the page report_error.php) that they are receiving "CARD_VALID"!
So, basically, it sounds like ('CARD_VALID' == 'CARD_VALID') is evaluating to false for certain users.
I have been logging the user agent and in the most recent case it was "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; (R1 1.5); .NET CLR 1.0.3705; .NET CLR 2.0.50727; MSN OptimizedIE8;ENUS)".
If anybody has had a similar experience or some advice on how to fix this, I would appreciate the help. Thanks.