未捕获的ReferenceError:Stripe未定义MVC

时间:2022-11-06 15:22:08

I have simple payment page which I am going to show in popup using partial view. In .cshtml page, I have following javascript code below html code:

我有简单的付款页面,我将使用局部视图在弹出窗口中显示。在.cshtml页面中,我在html代码下面有以下javascript代码:

<script type="text/javascript" src="https://js.stripe.com/v2/"></script>
<script type="text/javascript">
    $('document').ready(function () {
        Stripe.setPublishableKey(publishablekey);
    });
</script>

When I run the project that popup shows successfully but in the console, there is an error: Uncaught ReferenceError: Stripe is not defined

当我运行弹出窗口成功但在控制台中显示的项目时,出现错误:未捕获的ReferenceError:未定义条带

2 个解决方案

#1


0  

This happens when the browser cannot load the Stripe js library. That could happen because your user has lost their internet connection, or maybe (but less likely) the website that is serving the Stripe library is temporarily unavailable. To handle this case gracefully you could check to see whether Stripe is undefined.

当浏览器无法加载Stripe js库时会发生这种情况。这可能是因为您的用户丢失了他们的互联网连接,或者可能(但不太可能)服务Stripe库的网站暂时不可用。要优雅地处理这种情况,您可以检查Stripe是否未定义。

For example:

if (typeof Stripe === "undefined") {
    alert("Unexpected Error");
}

Or check for the opposite before using it

或者在使用之前检查相反的情况

if (typeof Stripe !== "undefined") {
    Stripe.setPublishableKey(publishablekey);
}

#2


0  

I just added Stripe reference line: <script type="text/javascript" src="https://js.stripe.com/v2/"></script> in that page on which I am going to show partial view in the popup.

我刚刚在该页面中添加了Stripe参考行:

#1


0  

This happens when the browser cannot load the Stripe js library. That could happen because your user has lost their internet connection, or maybe (but less likely) the website that is serving the Stripe library is temporarily unavailable. To handle this case gracefully you could check to see whether Stripe is undefined.

当浏览器无法加载Stripe js库时会发生这种情况。这可能是因为您的用户丢失了他们的互联网连接,或者可能(但不太可能)服务Stripe库的网站暂时不可用。要优雅地处理这种情况,您可以检查Stripe是否未定义。

For example:

if (typeof Stripe === "undefined") {
    alert("Unexpected Error");
}

Or check for the opposite before using it

或者在使用之前检查相反的情况

if (typeof Stripe !== "undefined") {
    Stripe.setPublishableKey(publishablekey);
}

#2


0  

I just added Stripe reference line: <script type="text/javascript" src="https://js.stripe.com/v2/"></script> in that page on which I am going to show partial view in the popup.

我刚刚在该页面中添加了Stripe参考行: