by prettyscripts on 2009-06-24 10:28:46 • Leave a comment »
misc • javascript • xajax
when passing a boolean value from javascript to a xajax function, the value is converted to string in the xajax function.
you need to compare the string value of the boolean value (from javascript) in xajax function.
eg, the following code in xajax function will not work:
PHP:
function my_xajax_function($flag) { | |
$obj = new xajaxResponse(); | |
$obj->assign('some_id_name', 'className', $flag? 'true_class' : 'false_class'); | |
return $obj; | |
} |
in the above code, the ‘false_class’ will always be assigned.
replace line 3 from above with the following:
$obj->assign(’some_id_name’, ‘className’, ($flag == “true") ? ‘true_class’ : ‘false_class’); Tags: boolean, javascript, xajax