脚本文件未加载 [英] Script file not loading

查看:113
本文介绍了脚本文件未加载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在把头撞在墙上.我非常了解Javascript/jQuery,因此看不到为何无法正常工作的原因.我已经尝试了2.0.3和1.10.2的相同结果.

I am beating my head against the wall on this. I know Javascript/jQuery well and I can not see the reason why this is not working. I've tried both 2.0.3 and 1.10.2 with the same results.

我正在尝试做一个测试以确保脚本文件已加载.我尝试了许多不同的方法,但没有任何效果.但是,当我单击源中的URL时,它将转到具有正确代码的正确文件.

I'm trying to just do a test to make sure the script file is loaded. I've tried a number of different methods, nothing is working. But when I click the url in the source, it goes to the correct file that has the right code.

这就是我想要做的.

$(document).ready(function() {
   alert('test');
});

如果我将其包含在<script>标记之间的页面中,它将起作用.但是,当从.js文件引用它时,则不是.

Which works if I include it in the page between <script> tags. But not when referencing it from a .js file.

这是我的加载方式:

<script type="text/javscript"
        src="http://localhost/kdev/views/dashboard/js/default.js"></script>

单击该URL,将带上面的警报将我带到正确的文件.

Clicking on that url takes me to the correct file with the alert above.

但是不起作用.怎么回事?我忘记了什么?我有错字吗?

But's not working. What the crap is going on? What did I forget? Do I have a typo?

整个页面:

<!doctype html>
<html>
<head>
   <title>Test</title>
   <link rel="stylesheet" href="http://localhost/kdev/public/css/default.css" />
   <script type="text/javscript" 
           src="http://localhost/kdev/public/js/jquery-2.0.3.min.js"></script>
   <script type="text/javscript"
           src="http://localhost/kdev/views/dashboard/js/default.js"></script>
</head>
<body>   
<div id="header">
    header
    <br />
    <a href="http://localhost/kdev/index">Index</a>
    <a href="http://localhost/kdev/help">help</a>
               <a href="http://localhost/kdev/dashboard/logout">logout</a>
        </div>

 <div id="content">
 Dashboard... logged in only    </div>
 <div id="footer">feet</div>
</body>
</html>

推荐答案

更改此项(您在'javascript'中错过了'a'字符)

Change this (You missed 'a' char in 'javascript')

 <script type="text/javscript"
        src="http://localhost/kdev/views/dashboard/js/default.js"></script>

对此:

<script type="text/javascript"
        src="http://localhost/kdev/views/dashboard/js/default.js"></script>

这篇关于脚本文件未加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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