我已经从网络下载了 jquery-validation-1.14.0.zip 文件。并且知道我正在尝试在我的项目中使用它,但我的问题是我不知道将文件夹(提取的文件)放在我的 wamp 文件夹中的确切位置,以及对任何一个进行哪些更改配置或 .htaccess 文件。因为我已经花了 3-4 天的时间来自己配置它,但最终没有任何选择,我在这里发布我的问题,以便这里的任何人都可以帮助我。
基本上这是我的
文件夹结构;-
C:\wamp\www\developer\jquery-validation
Controller :- C:\wamp\www\developer\application\controllers
如何调用我 View 中的脚本文件:-
<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 未找到 27 毫秒]
得到
http://localhost/developer/index.php/jquery-validation/dist/jquery.validate.js [HTTP/1.1 404 未找到 30 毫秒]
ReferenceError:$未定义
请无论如何让我摆脱所有这些..现在我完全沮丧.. 非常非常感谢提前..
问题仍然是相同的@praveen 和@ichadhr。为了更清楚地说明我的代码,这里有一个简单的 View :
<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 文件的文件夹和文件位置与我的代码中相同。
错误仍然相同
最佳答案
所有包含的资源都与
绑定(bind)base_url('path/to/script.js');
所有链接都会生成
site_url('controller/action/param');
关于javascript - 如何使用 eclipse-mars IDE 将 jquery 插件设置到我的 codeigniter 项目中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35299244/