简体   繁体   中英

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).

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'

You need to remove your second jQuery call:

<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.

line 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:

<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. The jquery on line 155 is being included after anythingslider. So it is resetting the jquery object ( It no longer has anythinslider). remove this line 155 jquery and change line 34 like this

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

* DUDE! what are you doing with ur scripts and css *
1.i agree with curt.
there are 4 places where you have included jquery and not evenywhere there is a check for existing jquery availability.
2.i have checked all your script files are loading correctly. 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

Try this code

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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