Jquery错误“Uncaught ReferenceError:SPR未定义”

时间:2022-11-06 15:03:38

I am trying to use jquery countdown from http://keith-wood.name/countdown.html. But I am getting strange kind of error. It says "Uncaught ReferenceError: SPR is not defined".

我正在尝试使用来自http://keith-wood.name/countdown.html的jquery倒计时。但我得到了一些奇怪的错误。它说“Uncaught ReferenceError:SPR未定义”。

Here is the link of my site and I am using Django as framework to work with jquery plugin.

这是我的网站的链接,我使用Django作为框架来使用jquery插件。

Following is my code.

以下是我的代码。

$year = {{ object.expire_date|date:"Y" }};
$month = {{ object.expire_date|date:"m" }};
$day = {{ object.expire_date|date:"d" }};

$exp_date = new Date( $year, $month -1, $day);

$("#defaultCountdown").countdown({
    until: $exp_date,
    onExpiry: fadeExpireOut

});
function fadeExpireOut(){
    $("#defaultCountdown").fadeOut();
}

I am using following tag to display the countdown.

我正在使用以下标签来显示倒计时。

<span id="defaultCountdown"></span>

Please see error details by inspecting element. The same code is working fine in development but not at production server.

请通过检查元素查看错误详细信息。相同的代码在开发中工作正常,但在生产服务器上却没有。

1 个解决方案

#1


0  

You have this javascript statement:

你有这个javascript声明:

 SPR.$("textarea[data-product-id=3712888641]").keyup(sprUpdateCount).trigger("keyup");

that gets executed immediately and, at the time it is executed, the variable SPR doesn't exist.

立即执行,并且在执行时,变量SPR不存在。

Looking at your link, the offending code is at line 2631, inside the following script block:

查看您的链接,违规代码位于以下脚本块内的第2631行:

<script type="text/javascript" charset="utf-8">
          function sprUpdateCount(e){
            var $el = SPR.$(e.currentTarget);
            SPR.$(".spr-form-review-body-charactersremaining").html('(' + (1500 - $el.val().length) + ')');
          }
          SPR.$("textarea[data-product-id=3712888641]").keyup(sprUpdateCount).trigger("keyup");
</script>

#1


0  

You have this javascript statement:

你有这个javascript声明:

 SPR.$("textarea[data-product-id=3712888641]").keyup(sprUpdateCount).trigger("keyup");

that gets executed immediately and, at the time it is executed, the variable SPR doesn't exist.

立即执行,并且在执行时,变量SPR不存在。

Looking at your link, the offending code is at line 2631, inside the following script block:

查看您的链接,违规代码位于以下脚本块内的第2631行:

<script type="text/javascript" charset="utf-8">
          function sprUpdateCount(e){
            var $el = SPR.$(e.currentTarget);
            SPR.$(".spr-form-review-body-charactersremaining").html('(' + (1500 - $el.val().length) + ')');
          }
          SPR.$("textarea[data-product-id=3712888641]").keyup(sprUpdateCount).trigger("keyup");
</script>