javascript: calling xajax functions with boolean parameter

by prettyscripts on 2009-06-24 10:28:46

miscjavascriptxajax

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

No feedback yet

Leave a comment


Your email address will not be revealed on this site.
PoorExcellent
note: all comments are moderated. do not spam and do not advertise. only comments relevant to the post will be published.
(Line breaks become <br />)
(For my next comment on this site)
(Allow users to contact me through a message form -- Your email will not be revealed!)