jQuery javascript在codeigniter中不起作用 [英] jquery javascript doesnt work in codeigniter

查看:65
本文介绍了jQuery javascript在codeigniter中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,感恩节快乐!

我在将这个脚本包含在codeigniter中时遇到了一些问题:

i am some problem to include this script in codeigniter:

<script type="text/javascript" src="<?php echo base_url();?    application/views/jquery.js">
</script>
<script type="text/javascript">
    $(document).ready(function() {
        setInterval(function () {
            $('#show').load('<?php $this->load->view('data');?>')
//im tryng also $('#show').load('<?php echo base_url();?>application/views/data.php') but it doesnt work anyway
        }, 3000);
    });


</script>

此功能可以使codeigniter正常工作吗? 也许我在配置文件中有问题? idont知道...请为我的英语不好对不起 最好的问候

this function out codeigniter work without problem ? maybe i have some problem in configuration file ? idont know ... please write me sorry for the bad english best regards

推荐答案

另一种方法如下.

<script type="text/javascript" src="<?= base_url('application/views/jquery.js'); ?>">

在这种情况下,$config['base_url']的结尾是/

In this case $config['base_url'] has a trailing /

如果您尝试直接在应用程序/视图下访问文件,则会收到404错误.那是你的问题吗?

If you are trying to access files directly under applications/views you will get a 404 error. Is that your issue?

通常,您会将所有公共端的css和js文件放在类似...的结构下

Normally you would put all your public side css and js files under a structure like...

Your Document Root Folder/
                         assets/
                               js/
                                  jquery.js
                               css/

那么您就可以了

  <script type="text/javascript" src="<?= base_url('assets/js/jquery.js'); ?>">

然后您可以正确访问它.

And then you can access it correctly.

诀窍是...在浏览器中查看HTML源代码,查看jquery所具有的链接,然后单击它,然后查看错误消息的含义.

The trick is... view your HTML source code on the browser, view the link you have for your jquery and click on it and see what the nice error message says.

如果一切正常,那么您将看到实际的文件源.

if it all works, then you will see the actual file source.

这篇关于jQuery javascript在codeigniter中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆