codeigniter javascript not found错误 [英] codeigniter javascript not found error

查看:91
本文介绍了codeigniter javascript not found错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,我很抱歉我的英语不好,我很西班牙语,如果我做错了,我很抱歉,这是我的第一篇文章。

First of all, I am sorry for my bad english, I am spanish and I am sorry if I have made something wrong, this is my first post.

我在codeigniter 2.1.4中加载javascript文件时遇到问题。我没有把它加载到我页面的标题中。 css文件装得很好。此示例尝试加载jquery和bootstrap。

I have a problem with loading a javascript file in codeigniter 2.1.4. I didn´t get loaded it in the header of my page. The css files were well loaded. This example attempts to load jquery and bootstrap.

我遵循codeigniter文档中的步骤,当我创建codeigniter静态页面home.php时,我想要使用bootstrap进行设计。

I am following the steps in the documentation of codeigniter and when I create the codeigniter static page "home.php" I want to use bootstrap for design.

我遵循的教程是:
http://ellislab.com/codeigniter/user-guide/tutorial/static_pages.html

我的文件夹结构:



  • htdocs


    • myproject(curriculos)


      • application


        • controller


          • pages.php


  • templates


    • header.php


    • home.php

    • about.php


    • bootstrap


      • css


        • bootstrap.min.css


        • bootstrap.min.js

        我一直在这个论坛和其他人搜索,我总是找到与base_url()或site_url()相同的例子。这些是我的:

        I have been searching in this forum and others and always I find the same example with base_url() or site_url(). These are mine:

        更新的代码:

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

        我的autoload.php加载了url helper:

        My autoload.php with url helper loaded:

        $ autoload['helper'] = array('url');
        

        当我尝试加载页面时出现以下错误:

        When I try to load the page I get these errors:

        GET http://localhost/curriculos/assets/jquery-2.1.0.min.js 404 (Not Found)
        GET http://localhost/curriculos/assets/bootstrap/js/bootstrap.min.js 404 (Not Found)
        GET http://localhost/curriculos/assets/bootstrap/js/bootstrap.min.js 404 (Not Found) 
        

        最奇怪的是当你点击其中一个时它会显示你正在尝试加载文件类型作为text / html而不是像往常一样的应用程序/ javascript:

        The strangest is that when you click on one of them it shows you that the file type is trying to be loaded as a text/html and not as an application/javascript as usual:

        你能帮助我吗?

        谢谢非常感谢您的回复。

        Thank you very much for your reply.

        推荐答案

        您需要更改.htaccess文件,以便它不再重写对' / assets'。

        You need to change your .htaccess file so that it no longer rewrites requests made to '/assets'.

        换句话说,您需要.htaccess文件来忽略请求t o'assets'文件夹,让浏览器加载提供的url。试试这个:

        In other words, you need your .htaccess file to ignore requests to the 'assets' folder and just let the browser load the url as provided. Try this:

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

        这篇关于codeigniter javascript not found错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆