user2958359
user2958359

Reputation: 131

jQuery showing unexpected result in codeigniter

I have the following file structure in codeigniter..

applications/...
system/...
assets/js

and under the js folder i have included the downloaded jQuery file and my script named a.js

In the head section i have also included their links. As below:

<script  type="text/javascript" src="<?php echo base_url();?>assets/js/a.js"></script>
<script  type="text/javascript" src="<?php echo base_url();?>assets/js/jquery.js"></script>

my a.js contains only the following code

$(document).ready(function(){
    alert("loaded"):

});

But it is not showing any alert whenever I reload the page. But the same code runs fine when i do not use codeigniter. However inline jQuery is working. For example the following code is working..

<p onclick="$(this).hide();" > CLICK ME AND I WILL HIDE </p> 

What is the problem. How to fix or where I am doing wrong. Please help me....

Upvotes: 0

Views: 45

Answers (1)

Ali
Ali

Reputation: 782

Change your header for including js

<script  type="text/javascript" src="<?php echo base_url();?>assets/js/jquery.js"></script>

<script  type="text/javascript" src="<?php echo base_url();?>assets/js/a.js"></script>

Upvotes: 1

Related Questions