【问题标题】:jquery script does not executejquery脚本不执行
【发布时间】:2012-09-16 08:57:50
【问题描述】:

目前,我正在使用 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>

【问题讨论】:

  • &lt;script type="text/javascript" src="/ci/js/jquery-1.7.1.js"&gt;&lt;/script&gt;
  • 127.0.0.1/ci/welcome/passdataview/6/7 没有任何“URL 中的参数”。是不是类似于127.0.0.1/ci/welcome/passdataview?username=6&amp;subject=7

标签: php jquery codeigniter


【解决方案1】:

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

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

无论您如何更改文件夹或目录路径都有效。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-04-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多