how to call a javascript function from my controller?
<p>Hi 
    I have a form in my view page on submit a function in a controller called <code>function Login()</code> is called 
This is my Login function</p>

<pre><code>function Login()
{   
     $EmailId = $this-&gt;input-&gt;post('mailId');
     $Password = $this-&gt;input-&gt;post('password');
     $res=$this-&gt;friendsmodel-&gt;CheckLogin($EmailId,$Password);
     if($res==true)
     {

         $_SESSION['Authenticaton_user']="auth_user";
         $this-&gt;session-&gt;set_flashdata('item', 'Thanks for logging in');
                      //I want to call javascript function from here
         redirect('friends/Display_News');
     }
     else 
     {
      $this-&gt;session-&gt;set_flashdata('item', 'Username Or Password is invalid');
         redirect('friends');
     }

}
</code></pre>

<p>Now want to call a javascript function named <code>topBar()</code> from my if and else statement
This is my script</p>

<pre><code> function topbar(message) 
{
       var alert = $('&lt;div id="alert"&gt;'+message+'&lt;/div&gt;');
        $(document.body).append(alert);
        var $alert = $('#alert');
        if ($alert.length) {
            var alerttimer = window.setTimeout(function() {
                $alert.trigger('click');
            }, 5000);
            $alert.animate({ height: $alert.css('line-height') || '50px' }, 200).click(function() {
                window.clearTimeout(alerttimer);
                $alert.animate({ height: '0' }, 200);
            });
        }
}
</code></pre>

<p>How to call a javascript from here</p>
