如何使用eclipse-mars IDE将jquery插件设置到我的codeigniter项目中


I have downloaded jquery-validation-1.14.0.zip file from web. And know I am trying to use it in my project, but the problem with me is i don't know exactly where to place the folder(extracted file) in my wamp folder, and what are the changes to be made on any of the config or .htaccess file. As i have given all my complete 3-4 days to configure it by my own, but finally left with no options and i am posting my question here so that anyone here can help me out. basically here is my folder sructure;- C:\wamp\www\developer\jquery-validation

controller:- C:\wamp\www\developer\application\controllers

How do i use to call the script file in my 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>

And another thing that i would like to emphasis here is, in eclipse-mars, i have included jquery library too. And now i have jquery 2.0 library inside Javascript Resources.

After doing all these when i simply try to use alert function, i got to see lots of errors. Errors:-
GET http://localhost/developer/index.php/jquery-validation/lib/jquery.js [HTTP/1.1 404 Not Found 27ms]
GET http://localhost/developer/index.php/jquery-validation/dist/jquery.validate.js [HTTP/1.1 404 Not Found 30ms]
ReferenceError: $ is not defined

Please get me rid of all these anyhow.. Now i'm totally frustrated.. Very Very Thanks in advance..

the problem remains the same @praveen and @ ichadhr. For more clarification of my code, here is a simple 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>


And my base url is localhost/developer
and the folder and file locations for js file are as in my code.
Errors are still same

dsa456369
dsa456369 试试这个<scripttype=“text/javascript”src=“<?phpechobase_url(”/jquery-validation/lib/jquery.js“);?>”></script>
4 年多之前 回复

2个回答



所有包含的资产都与</ p>

  base_url('path / to / script)绑定。  js'); 
</ code> </ pre>

所有链接都生成</ p>

  site_url('controller / action / param')  ; 
</ code> </ pre>
</ div>

展开原文

原文

All included assets bind with

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

And all links generate with

site_url('controller/action/param');



在看到您的新描述后,假设文件位于应用程序内的views文件夹中,那么变为: - </ p>

< pre> &lt; html&gt;
&lt; head&gt;
&lt; script type =“text / javascript”src =“&lt;?php echo base_url('jquery-validation / lib / jquery.js');?&gt; ;” &gt;&lt; / script&gt;
&lt; script type =“text / javascript”src =“&lt;?php echo base_url('jquery-validation / dist / jquery.validate.js');?&gt;”&gt;&lt; ; / script&gt;
&lt; / head&gt;
&lt; body&gt;
&lt; form method =“post”id =“myform”&gt;
&lt; div class =“form-group”&gt;
&lt; label for = “name”&gt;名称:&lt; / label&gt;
&lt; input type =“text”class =“form-control”name =“name”id =“name”&gt;
&lt; / div&gt;
&lt; button type =“submit”class =“btn btn-default”id =“sub”&gt;提交&lt; / button&gt;
&lt; / form&gt;

&lt; script&gt;
jQuery(document).ready(function($) {
$(“#sub”)。click(function(){
alert(“hello”);
});
});
&lt; / script&gt;
&lt; / body&gt;
&lt; ; / html&gt;
</ code> </ pre>
</ div>

展开原文

原文

After Seeing your new description assuming files are in your views folder inside application So the becomes :-

<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>

douli1854
douli1854 欢迎@PratikLalan在浏览器中打开你的jquery.js,如果url是这样的文件:/// C:/wamp/www/developer/jquery-validation/lib/jquery.js然后放在文件后面:/// C :/ wamp / www / developer /(在这种情况下是jquery-validation / lib / jquery.js)到base_url('jquery-validation / lib / jquery.js')就像这样:)
4 年多之前 回复
dougou7782
dougou7782 并感谢你们的帮助。 @Praveen Kumar
4 年多之前 回复
dtv7174
dtv7174 我知道代码很容易实现,但是你可以让我知道是否有任何预配置需要处理jquery? 在config,htacces等文件中。 因为我已经做了一些配置,但万一我可能会遗漏一些。 (错误保持不变,就像未定义jquery一样)
4 年多之前 回复
dtz46697
dtz46697 现在检查
4 年多之前 回复
duanbing6955
duanbing6955 请参考上面我添加的更清晰的描述。
4 年多之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐