Using jQuery 1.9.1, calling back to the server to check some data:
$form = $("#form2")
var str = $form.serialize();
status = true;
$.ajax({
type : 'POST',
url : 'check_zip.php',
data : str,
async : false,
success : function (data) {
obj = JSON.parse(data);
var result = obj.result;
status = result;
},
error : function (msg) {
alert(msg);
status = false;
}
});
if (status == "false" || status === false) {
....
I found that Chrome would return status "false" (string) and Firefox would return status false (boolean). Is this expected behavior? I was astonished!
The JSON being parsed is data: "{"result":false}"
typeof(status) is string in Chrome and boolean in FF.
The issue seems to arise here:
var result = obj.result;
status = result;
Because the datatype of result in Chrome is boolean, whereas the datatype of status is string.
"false"
andfalse
couldn't be bigger. They're absolutely not the same thing. – Halcyonfalse
and not undefined in ff? Could you post the output oftypeof status
? – bfavaretto