简体   繁体   English

Javascript本地加载但不在服务器上

[英]Javascript loading locally but not on server

I have looked at similar threads but have yet to find a solution to this problem. 我看过类似的线程,但尚未找到解决此问题的方法。

The website is working perfectly on my local machine (Mac), but I have uploaded a website via FTP (hosted by 1&1) and when I view the site in the browser (latest Chrome/Firefox/Safari) the scripts are not loading for the image slider (AnythingSlider). 该网站可以在我的本地计算机(Mac)上正常运行,但是我已经通过FTP(由1&1托管)上传了一个网站,并且当我在浏览器(最新的Chrome / Firefox / Safari)中查看该网站时,脚本无法加载图像滑块(AnythingSlider)。

View the website 浏览网站

Apologies if this is answered elsewhere. 抱歉,如果在其他地方回答。

Checking your script you have the following error: 检查脚本时出现以下错误:

Uncaught TypeError: Object [object Object] has no method 'anythingSlider' 未捕获的TypeError:对象[object Object]没有方法'anythingSlider'

You need to remove your second jQuery call: 您需要删除第二个jQuery调用:

<script>window.jQuery || document.write('<script src="js/libs/jquery-1.7.2.min.js"><\/script>')</script>

This will prevent jQuery from "restarting", which will prevent you from losing the anythingSlider function. 这将防止jQuery“重新启动”,这将防止您丢失anythingSlider函数。

line 155 : 155行:

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>

<script>window.jQuery || document.write('<script src="js/libs/jquery-1.7.2.min.js"><\/script>')</script>

line 20: 第20行:

<script src="js/libs/jquery-1.7.2.min.js"></script>
<script>window.jQuery || document.write('<script src="js/libs/jquery-1.7.2.min.js"><\/script>')</script>

Don't include jQuery twice. 不要两次包含jQuery。 The jquery on line 155 is being included after anythingslider. 155行上的jquery被包含在everythingslider之后。 So it is resetting the jquery object ( It no longer has anythinslider). 因此,它正在重置jquery对象(它不再具有anythinslider)。 remove this line 155 jquery and change line 34 like this 删除此行155 jquery并更改第34行,如下所示

<script>    
    $(document).ready(function(){
        $('#slider').anythingSlider();
    });
</script>

* DUDE! * 老兄! what are you doing with ur scripts and css * 您在用您的脚本和CSS做些什么 *
1.i agree with curt. 1.i同意。
there are 4 places where you have included jquery and not evenywhere there is a check for existing jquery availability. 有4个地方包含了jquery,而没有jeven的地方检查了现有jquery的可用性。
2.i have checked all your script files are loading correctly. 2.i已检查所有脚本文件是否正确加载。 so the problem isnt of loading the files. 所以问题不是加载文件。 with it you are using incorrect urls to load you script. 使用它,您使用了错误的网址来加载脚本。 3.finally you should use $(document).ready() event for anything tht needs to be executed after dom ready 3,最后,在准备好dom之后需要执行的任何操作都应使用$(document).ready()事件

Try this code 试试这个代码

<script defer type="text/javascript">
    // DOM Ready
    $(document).ready(function () {
        $('#slider').anythingSlider();
    });
</script>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM