wyc
wyc

Reputation: 55273

External JavaScript working on localhost but not in remote host?

This is the site: http://www.hfwebdesign.com/

I'm getting this error: Uncaught TypeError: Object [object Object] has no method 'flexslider'

But in my localhost it works perfectly.

This is the <head> (where the script is being called):

<head>
<meta charset="<?php bloginfo( 'charset' ); ?>" />
<meta name="viewport" content="width=device-width" />
<title><?php wp_title( '|', true, 'right' ); ?></title>
<link rel="profile" href="http://gmpg.org/xfn/11" />
<link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>" />
<link rel="stylesheet" type="text/css" media="all" href="<?php bloginfo( 'template_url' ); ?>/js/flexslider/flexslider.css" />
<link rel="icon" type="image/png" href="<?php bloginfo( 'template_url' ); ?>/favicon.ico" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="<?php bloginfo( 'template_url' ); ?>/js/flexslider/jquery.flexslider-min.js"></script>
<?php // Loads HTML5 JavaScript file to add support for HTML5 elements in older IE versions. ?>
<!--[if lt IE 9]>
<script src="<?php echo get_template_directory_uri(); ?>/js/html5.js" type="text/javascript"></script>
<![endif]-->
<?php wp_head(); ?>
</head>  

footer:

<script type="text/javascript">
  var $j = jQuery.noConflict();
  $j(document).ready(function() {
    $j('.flexslider').flexslider({
      animation: "slide"
    });
  });
</script>

</body>

Could it be that the code is breaking in the web server in the remote host and not in my localhost (e.g. they are different version of LAMP/APACHE?)

Upvotes: 0

Views: 1894

Answers (2)

chikeet
chikeet

Reputation: 1

Check case in your script path. If the script folder name is e.g. 'flexSlider' and in the script src path is 'flexslider', it will work on windows (most localhosts) but not on linux (most servers). It depends on the OS, not on the server SW, so running e.g. XAMPP on windows will work because windows works in case-insensitive way with paths.

Upvotes: 0

Guerra
Guerra

Reputation: 2790

Try chage the call place from:

<script src="http://www.hfwebdesign.com/wp-content/themes/twentytwelve/js/flexslider/jquery.flexslider-min.js.pagespeed.jm.noGKd8vLzs.js"></script>
<script type='text/javascript' src='http://www.hfwebdesign.com/wp-includes/js/jquery/jquery.js,qver=1.8.3.pagespeed.jm.1SksPi3j41.js'></script>

To:

<script type='text/javascript' src='http://www.hfwebdesign.com/wp-includes/js/jquery/jquery.js,qver=1.8.3.pagespeed.jm.1SksPi3j41.js'></script>
<script src="http://www.hfwebdesign.com/wp-content/themes/twentytwelve/js/flexslider/jquery.flexslider-min.js.pagespeed.jm.noGKd8vLzs.js"></script>

Don't sure about it, but try isn't bad.

Upvotes: 1

Related Questions