Jquery and codeigniter

and sorry if this question is stupid I'm trying to use javascript with codeigniter, and I can’t get it right what I'm actually doing is placing jQuery inside the views folder and calling it from one of my view files for example:

<script type="text/javascript" src="jquery.js"></script>

I don’t get an answer without errors, it just doesn’t work, I can also display more code, but my first assumption is that something is wrong with what I call it ... maybe something with paths?

any workarounds?

thanks in advance

+3
source share
3 answers

Put jquery.js in the root of your site and use:

<script type="text/javascript" src="/jquery.js"></script>

js, :

<script type="text/javascript" src="/js/jquery.js"></script>

:

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

+4

, .htaccess Codeigniter, URL- Codeigniter:

RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

jquery.js, index.php; , :

RewriteCond $1 !^(index\.php|images|jquery\.js|robots\.txt)
+1

bretticu ( ellilab) beCause base_url();

css, .js , . , , can htaccess , .

RewriteEngine on RewriteCond $1 !^(index\.php|css|images|js\.js|robots\.txt|favicon\.ico) RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ /index.php/$1 [L]

:

0

Source: https://habr.com/ru/post/1749582/


All Articles