Welcome Guest, Not a member yet? Register   Sign In
How to inlucde external javascipt libraries
#1

[eluser]Unknown[/eluser]
I have a web page which needs to include external javascript libraries. I have downloaded them and include in the php->libraries folder. My application is hosted in openshift cloud. I want to include those javascript files in my php file. I have used this code

script src="../../libraries/dhtmlxCalendar/dhtmlxCalendar/codebase/dhtmlxcalendar.js">

But it is not working

then I tried

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

The base url gives me the url but it is also not working.

What is the correct way for this ? I am a beginner for codeigniter. Could you help me
#2

[eluser]ricmen[/eluser]
did you have an .htaccess in which you are re writing the index.php?
if so then you have to add the js extension in RewriteCond

like this


# Allow these directories and files to be displayed directly:
RewriteCond $1 ^(index\.php|txt|js|robots\.txt|images|css|opensearch\.xml|favicon\.ico|assets|forums)
#3

[eluser]Unknown[/eluser]
My .htaccess files is like this now

RewriteEngine on
RewriteCond $1 ^(index\.php|txt|js|robots\.txt|images|css|opensearch\.xml|favicon\.ico|assets|forums)
RewriteRule ^(.*)$ /index.php/$1 [L]

Now can I use the

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

line to include the javascripts ?
#4

[eluser]ricmen[/eluser]
well if works tell me please to know

my .htaccess file is this

<IfModule mod_rewrite.c>
# Turn on URL rewriting
RewriteEngine On

# If your website begins from a folder e.g localhost/my_project then
# you have to change it to: RewriteBase /my_project/
# If your site begins from the root e.g. example.local/ then
# let it as it is
RewriteBase /MYAPP/

# Protect application and system files from being viewed when the index.php is missing
RewriteCond $1 ^(application|system|private|logs)

# Rewrite to index.php/access_denied/URL
RewriteRule ^(.*)$ index.php/access_denied/$1 [PT,L]

# Allow these directories and files to be displayed directly:
RewriteCond $1 ^(index\.php|txt|js|robots\.txt|images|css|opensearch\.xml|favicon\.ico|assets|forums)

# No rewriting
RewriteRule ^(.*)$ - [PT,L]

# Rewrite to index.php/URL
RewriteRule ^(.*)$ index.php/$1 [PT,L]
</IfModule>
#5

[eluser]CroNiX[/eluser]
Hard to tell with your relative (not good) path, but if that is within the /application or /system dir that's why it doesn't work...those are not publicly accessible for security reasons. Just like you can't go to http://yoursite.com/application/controll...roller.php
#6

[eluser]InsiteFX[/eluser]
All your assets files should be in a directory called assets in the root where index.php is.

Code:
application
system
index.php
assets
-- css
-- js
-- etc

&lt;link href="&lt;?php echo base_url('assets/css/bootstrap.css'); ?&gt;" rel="stylesheet"&gt;

// change $ to s in script tags.
<$cript src="&lt;?php echo base_url('assets/js/jquery.js'); ?&gt;"></$cript>





Theme © iAndrew 2016 - Forum software by © MyBB