jquery脚本不执行

时间:2012-09-16 08:57:50

标签: php jquery codeigniter

目前,我正在使用jquery,php和codeigniter来编写程序 - 但是,我遇到了一个问题。

当我使用codeigniter php框架编写视图文件时,我无法使用URL 127.0.0.1/ci/welcome/passdataview/6/7执行JQuery。如果我使用127.0.0.1/ci/welcome/passdataview,则可以执行JQuery脚本。

有人能告诉我如何使用URL中的codeigniter参数执行jquery脚本吗?

<html>
<head>
<script type="text/javascript" src="../js/jquery-1.7.1.js"></script>
<script type="text/javascript">

$(document).ready(function(){
alert ("here");
});

</script>
</head>
<body>
<div><h2>demo 1</h2></div>
<input type="hidden" id="hidden1" value="<?php echo $username;?>">
<input type="hidden" id="hidden2" value="<?php echo $subject;?>">
</body>
</html>

1 个答案:

答案 0 :(得分:4)

可能是你的jquery文件问题,请尝试加载url helper并使用它:

<script type="text/javascript" src="<?php echo base_url('js/jquery-1.7.1.js');?>"></script>

无论您如何更改文件夹或目录路径,都可以正常工作。

相关问题