【问题标题】:jQuery Cycle Uncaught SyntaxError: Unexpected end of inputjQuery Cycle Uncaught SyntaxError:输入意外结束
【发布时间】:2013-08-12 16:53:13
【问题描述】:

我正在使用 jQuery 循环创建一些画廊,一切都很棒,在本地。但是在服务器上我收到以下两条错误消息:

未捕获的 SyntaxError:输入 jquery-cycle.js:1 意外结束

Uncaught TypeError: Object [object Object] has no method 'cycle

包括jQuery和Cycle:

<script src="<?php bloginfo('template_url'); ?>/js/jquery-latest.js" type="text/javascript"></script>
<script src="<?php bloginfo('template_url'); ?>/js/jquery-cycle.js" type="text/javascript"></script>

我的 jQuery 循环函数:

    <script>
      $(function() {
        $('#mini-gallery').cycle({
          speed: 800,
          timeout: '6500',
          pause: 'true',
          cleartypeNoBg: 'false',
          containerResize:0,
          slideExpr: '.testimonial-mini-item'       
        });
       });
     </script>

为什么我会在实时服务器上收到这些错误消息?

更新

我已将加载 Cycle 插件的方式更改为:

   <script src="http://malsup.github.io/jquery.cycle.all.js"></script>

现在插件运行良好。任何想法为什么现在有效?这与我使用服务器 IP 地址而不是域这一事实有关吗?

【问题讨论】:

  • 检查你的网络(Firebug,或者webkit提供的东西,如果你使用chrome)看看你是否真的下载了插件

标签: php jquery syntax-error cycle


【解决方案1】:

我会仔细检查以确保您的 jquery-cycle.js 文件没有缺少括号或其中没有导致页面在加载时失败的东西。

【讨论】:

  • 我认为没有错误,我直接从网站下载了插件。本地主机上没有错误。
  • 在那种情况下,我不太确定,抱歉。当解析器在某处需要一个右括号但没有找到它时,我通常会发现这个错误。我会确保它不会在您的代码中的其他地方丢失。请务必检查 PHP 代码,可能是 PHP 条件导致您的 JS 代码在您的站点上时中断,但在本地时不会中断。
【解决方案2】:

我已将加载 Cycle 插件的方式更改为:

 <script src="http://malsup.github.io/jquery.cycle.all.js"></script>

现在插件运行良好。任何想法为什么现在有效?这与我使用服务器 IP 地址而不是域这一事实有关吗?

【讨论】:

    猜你喜欢
    • 2023-03-21
    • 2016-08-05
    • 1970-01-01
    • 2019-12-27
    • 2015-08-05
    • 1970-01-01
    • 2020-03-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多