Issue
How to call javascript function in controller as below
In example.js
function hello(){
alert("hi");
}
In exampleController.php
function index(){
hello();
}
Solution
You can't call JavaScript function from the controller,
controller is running on server-side, and your java script code running under the browser/client side.
If you want to call javaScript function you must have to render view and call from that.
You can also try
$this->Html->scriptBlock('alert("hi")');
code to call javaScript function from the view.
Answered By - Binary Brackets
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.