CodeIgniter Forums
CI AND JQUERY - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: CI AND JQUERY (/showthread.php?tid=45077)



CI AND JQUERY - El Forum - 09-07-2011

[eluser]Tanvir[/eluser]
Hello, I m new to CI. I tried using jquery the following way-
My Controller-
Code:
<?php
class Blog extends CI_Controller{
    public function __construct()
    {    parent :: __construct() ;
            $this->load->helper('url');

    }
    public function index()
    {    }
    public function ajaxShow(){
    $this->load->view("ajaxDemo_view");
    }
}
?>
My View file-
Code:
<html>
<head>
[removed][removed]
[removed] [removed]
</head>
&lt;body&gt;&lt;button id='show'> DISPLAY</button> <p>
&lt;/body&gt;&lt;/html>
ANd here is the javascript file- ajaxDemo.js
Code:
$(document).ready(function() {
  alert ('Hello World');
});
I added script type='text/javascript' src=' &lt;?php base_url();?&gt;assets/js/jquery-1.6.1.js'and script type='text/javascript' src=' &lt;?php base_url();?&gt;assets/js/ajaxDemo.js'> in head section of the view file (which is removed in here)
I used a javascript file -ajaxDemo.js to show a simple alert(). IF Jquery and js files are loaded from view file, then shouldnt it work this way ?