I use the $ .post method to call ajax.I have a script (php) that checks for a user in the database and returns (echo's) 1 if it exists, and 0 if not. Is it possible to return true and false so that javascript recognizes it as logical?
http://api.jquery.com/jQuery.post/
mentions the data analysis option as JSON, so theoretically you can use php to echo data in json form.
No, values will always be returned as text. You need to compare the values in your JavaScript.
if (data == '1') { //it true } else { // it false }
"0" false JavaScript, "1" true, . === .
"0"
false
"1"
true
===
As far as I remember, js accepts 0 as false.
So you can use
if (ans) ...; else ...
I'm not sure, but try it!