• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
jquery

#1
[eluser]einsteinity[/eluser]
hi, i'm newbie in codeigniter

i am trying to link my page with external jquery..

i have tried to understand the tutorial about assets here. but i got stucked after this part
Code:
$route["asset/:any"] = "asset_controller/index";

can somebody give me an extra instruction to understand that part?


what i am trying to do is to create a page with accordion effect (at this time, i haven't used that assets manager).

i set my base url in config.php to
Code:
$config['base_url'] = 'http://localhost/ci/';
i have load the url helper and javascript library too..

in my view file there is a piece of code like this
Code:
<link rel="stylesheet" type="text/css" href="<? echo base_url(); ?>css/styles.css" />
and
Code:
<script type="text/javascript" src="<? echo base_url(); ?>javascript/jquery.js" ></script>

i tried to run those page from browser and i got no problem with the css.. it's loaded properly, but the jquery file isn't loaded..

i open the "inspect element" in chrome browser, and found a message
Failed to load resource: the server responded with a status of 404 (Not Found)

i test to hover the css url shown in that inspect element tools, and the url is correct.
but when i tried to hover the jquery url, the target url is different with the url shown in the inspect element tools
it's shown like this
Code:
http://localhost/ci/A/javascript/jquery.js
where it should be like this
Code:
http://localhost/ci/javascript/jquery.js

please tell me what i have done wrong? i will send the complete code too if needed..

#2
[eluser]Otemu[/eluser]
This does seem strange as all echo base_url() does is outputs your base url path, so it very strange your getting the extra 'A' when loading JavaScript, you sure you completely removed asset manager? anywhere you can put the site online to have a look as could be an encoding issue? or upload your code somewhere so we can take a look?

#3
[eluser]einsteinity[/eluser]
argh.. i wanted to send the code just now and i noticed that i forgot to back up the code and lots of change have been done to this file..

if you could take a look at jquery accordion page in here.

i copied the code from that page with a change in the javascript source which is located in
xampp/htdocs/javascript/jquery.js

so i write like this in the head area

Code:
<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="<?base_url();?>javascript/jquery.js">
<script type="text/javascript">
  $(document).ready(function() {
    $("#accordion").accordion();
  });
</script>

i think that it will be point to localhost/ci/javascript/jquery.js

the file is located in xampp/htdocs/ci/javascript/jquery.js

the code is located in a page call faq.php
so i create a function in controller like this

Code:
class A extends CI_Controller{
function tanyajawab()
{
  this->load->view('A/faq');
}
}

the last action i tried to do is to move the jquery file outside the ci folder. and the code can work as what it should be.. but of course that won't be the permanent solution.

#4
[eluser]InsiteFX[/eluser]
Code:
// Repalce the $ with s in script tags
<$cript type="text/javascript" src="&lt;?php echo base_url('javascript/jquery.js');?&gt;"></$cript>

Make sure the your ./application/config/config.php base_url ends with a slash.

Normally we setup assets like this.
Code:
application
system
assets
  -- css
  -- images
  -- img
  -- js
  -- etc;
index.php

Then your link would look like this.
Code:
// Repalce the $ with s in script tags
<$cript type="text/javascript" src="&lt;?php echo base_url('assets/js/jquery.js');?&gt;"></$cript>


#5
[eluser]einsteinity[/eluser]
the codes are missing..

#6
[eluser]einsteinity[/eluser]
the first solution is not working.. the target directory is now okay but i got a 404 error message from google chrome's inspect element..

the base_url has been rechecked..

the third solution got the same error with the first one.. :-(


#7
[eluser]InsiteFX[/eluser]
It should be https// not http://
Code:
&lt;link href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/&gt;

#8
[eluser]einsteinity[/eluser]
[quote author="InsiteFX" date="1339171217"]It should be https// not http://
Code:
&lt;link href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/&gt;
[/quote]

i tried to create a html page (not with CI), it can work with http.

#9
[eluser]InsiteFX[/eluser]
Seems funny I can not download it without https://

#10
[eluser]einsteinity[/eluser]
hmm.. i don't know why, but it works here.

as long as i remember, i don't set anything to my browser to automatically force https connection

back to the case.. is it because the controller or the htaccess file?


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2017 MyBB Group.