[eluser]oldrock[/eluser]
Put your Javascript code on the VIEW side (ie) where you load the html code and call your javascript function this both actions should happen only in the view the controller does not relate with javascript codes and funtions.
eg:
in view yourview.php
<html>
<head>
[removed]
function my_js_fn()
{
Your function definition goes here
}
[removed]
</head>
<body>
function can take place anywhere over here.
</body>
</html>
in controller yourcontroller.php
<?php
class Yourcontroller extends Controller
{
function index()
{
$this->load->view('yourview');
}
}
?>