Hello All,
In this blog we will discuss about how to pass CakePhp variable in javascript.
So firstly we will be initiallizing a variable in the function below i.e abc(),then set this variable in for the ctp file.
Example-
function abc(){
$this->layout=default;
$message="Hello;
$this->set('message'.$message);
}
Then in your abc.ctp you can access the variable by following conventions:-
Example-
<script type="text/javascript">
var message = <?php echo $message; ?>;//You can get the value set in from your controller
var wishing = Hello+message;
alert(wishing);
</script>
0 Comment(s)