trying to call javascript |
Alright, I don't know what your experience is with CodeIgniter but I'll try to guide you in the right direction.
You're trying to load a JavaScript file and call a function. Since JavaScript code is executed by the browser, you need to do this in the View. It is a best practice to separate logic and presentation. So what I like to do, is build an array in the Controller of all the JS and CSS file I will need, and output these in the view. Here is a really simple example of that: PHP Code: $data = array( In the View, you read these arrays and output the filenames to the final HTML document so the browser can load them. Then you can execute any JS function present in these scripts. PHP Code: <?php foreach($js as $filename): ?>
CodeIgniter 4 tutorials (EN/FR) - https://includebeer.com
/*** NO support in private message - Use the forum! ***/ |
Welcome Guest, Not a member yet? Register Sign In |