【问题标题】:How to setup jquery plugin into my codeigniter project using eclipse-mars IDE如何使用 eclipse-mars IDE 将 jquery 插件设置到我的 codeigniter 项目中
【发布时间】:2016-02-09 18:15:20
【问题描述】:


我已经从网上下载了 jquery-validation-1.14.0.zip 文件。并且知道我正在尝试在我的项目中使用它,但我的问题是我不知道将文件夹(提取的文件)放在我的 wamp 文件夹中的确切位置,以及要对其中的任何内容进行哪些更改配置或 .htaccess 文件。因为我已经给了我全部的 3-4 天来自己配置它,但最后没有选择,我在这里发布我的问题,以便这里的任何人都可以帮助我。 基本上这是我的 文件夹结构;- C:\wamp\www\developer\jquery-validation

控制器:- C:\wamp\www\developer\application\controllers

在我看来如何调用脚本文件:-

<html>
<head>
<script type="text/javascript" src ="../jquery-validation/lib/jquery.js">      </script>
<script  type="text/javascript" src ="../jquery-validation/dist/jquery.validate.js"> </script>
</head>

我想在这里强调的另一件事是,在 eclipse-mars 中,我也包含了 jquery 库。现在我在 Javascript 资源中有 jquery 2.0 库。

当我简单地尝试使用警报功能时,在完成所有这些之后,我看到了很多错误。 错误:-
得到 http://localhost/developer/index.php/jquery-validation/lib/jquery.js [HTTP/1.1 404 Not Found 27ms]
得到 http://localhost/developer/index.php/jquery-validation/dist/jquery.validate.js [HTTP/1.1 404 Not Found 30ms]
ReferenceError: $ 未定义

无论如何,请让我摆脱所有这些......现在我非常沮丧...... 非常非常感谢提前..

@praveen 和@ichadhr 的问题仍然相同。为了更清楚地说明我的代码,这是一个简单的视图:

<html>
<head>
<script type="text/javascript" src ="<?php echo base_url('jquery-validation/lib/jquery.js');?>" ></script>
<script  type="text/javascript" src ="<?php echo base_url('jquery-validation/dist/jquery.validate.js');?>"></script>
</head>
<body>
<form method="post" id="myform">
<div class="form-group">
<label for="name">Name:</label>
<input type="text" class="form-control" name="name" id="name">
</div>
<button type="submit" class="btn btn-default" id="sub">Submit</button>
</form>

<script>
$("#sub").click(function(){
    alert("hello");
    $("#myform").valid();
});
</script>
</body>
</html>


我的基本网址是 localhost/developer
并且 js 文件的文件夹和文件位置与我的代码中的一样。
错误还是一样

【问题讨论】:

  • 试试这个&lt;script type="text/javascript" src="&lt;?php echo base_url("/jquery-validation/lib/jquery.js");?&gt;"&gt;&lt;/script&gt;

标签: javascript php jquery eclipse codeigniter


【解决方案1】:

所有包含的资产都与

绑定
base_url('path/to/script.js');

所有链接都生成

site_url('controller/action/param');

【讨论】:

    【解决方案2】:

    在看到你的新描述后,假设文件位于应用程序内的视图文件夹中,所以变成:-

    <html>
    <head>
    <script type="text/javascript" src ="<?php echo base_url('jquery-validation/lib/jquery.js');?>" ></script>
    <script  type="text/javascript" src ="<?php echo base_url('jquery-validation/dist/jquery.validate.js');?>"></script>
    </head>
    <body>
    <form method="post" id="myform">
    <div class="form-group">
    <label for="name">Name:</label>
    <input type="text" class="form-control" name="name" id="name">
    </div>
    <button type="submit" class="btn btn-default" id="sub">Submit</button>
    </form>
    
    <script>
    jQuery(document).ready(function($){
    $("#sub").click(function(){
        alert("hello");
    });
    });
    </script>
    </body>
    </html>
    

    【讨论】:

    • 参考上面我添加的更清晰的描述。
    • @PratikLalan 立即查看
    • 我知道代码很容易实现,但你能告诉我是否需要任何预配置来处理 jquery?在配置,htacces 等文件中。因为我已经做了一些配置,但万一我可能会遗漏一些。 (错误保持不变,如 jquery 未定义)
    • 感谢 praveen 提供的一致性帮助。 @Praveen Kumar
    • 欢迎@PratikLalan 在浏览器中打开您的 jquery.js,如果 url 类似于 file:///C:/wamp/www/developer/jquery-validation/lib/jquery。 js 然后将部分放在 file:///C:/wamp/www/developer/ 之后(在这种情况下是 jquery-validation/lib/jquery.js) 像这样进入 base_url('jquery-validation/lib/jquery.js') :)
    猜你喜欢
    • 2010-12-03
    • 2016-06-28
    • 1970-01-01
    • 1970-01-01
    • 2015-12-15
    • 1970-01-01
    • 1970-01-01
    • 2016-04-25
    • 1970-01-01
    相关资源
    最近更新 更多