简体   繁体   English

Javascript 不能在 Pythonanywhere 上运行

[英]Javascript doesn't run on Pythonanywhere

Here is my HTML code with some javascript:这是我的 HTML 代码和一些 javascript:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="/static/css/styles.css">
    <link rel="shortcut icon" href="/static/img/logo_BDS.png" type="image/png">
    <!-- IMPORT JQUERY -->
    <script src="http://code.jquery.com/jquery-2.2.1.min.js"></script>
    <!-- IMPORT SDK LYDIA -->
    <script type="text/javascript" src="/static/LYDIASDK.js"></script>
    <title>Confirm Checkout | BDS</title>
</head>
<body class="bg-gray-50">
    <div class="flex justify-center items-center">
        <div>
            <div class="flex justify-center mt-8 md:mt-36">
                <img src="/static/img/logo_BDS.png" class="h-56" alt="">  
            </div>
    
            <div class="bg-white rounded-lg shadow-lg text-gray-700 space-y-8 px-10 py-6" style="font-family: Avenir;">
                <h2 class="text-center text-rouge-phelma text-3xl">Vérification des informations</h2>
                <h4 class="text-center text-xl">{{nb_tickets}} ticket(s) pour {{ total_price }}€</h4>
                <h4 class="text-center text-xl">Ton numéro de téléphone est le suivant : {{tel_number}}</h4>
                <div class="flex justify-center">
                    <button class="px-3 py-2 bg-rouge-phelma text-white text-xl font-bold rounded-lg focus:ring-2 focus:outline-none focus:ring-rouge-phelma" type="submit" id="paymentButton">Payer via Lydia !</button>
                </div>
                
            </div>
        </div>
    </div>
    <input type="hidden" id="foo" value="{{nb_tickets}}">
    <div class="hidden" id="tel_number">{{tel_number}}</div>
    
    

    <script type="text/javascript">
        $(document).ready(function() {
            // Doit être la référence de la commande chez le marchand.
            var orderRef = new Date();
            // var nb_tickets = document.getElementById("nb-tickets").value;
            // var tel_number = document.getElementById("tel_number").value;
            // var total_price = 2*$('#nb-tickets').val();
        $('#paymentButton').payWithLYDIA({
            amount: $('input#foo').val()*2,
            vendor_token: 'my vendor token',
            recipient: $('div#tel_number').text(),
            browser_success_url : "https://www.ecosia.org/",
            browser_cancel_url  : "https://www.google.fr/",

            message : "blabla",
            orderRef: orderRef.toString(),
        });
        });
    </script>
</body>
</html>

All is working properly on my local dev server but the javascript part doesn't want to run on Pythonanywhere.一切都在我的本地开发服务器上正常工作,但 javascript 部分不想在 Pythonanywhere 上运行。 Does running an app on python anywhere with Flask change from running an app on the Flask local dev server?在 Flask 的任何地方运行 python 上的应用程序是否与在 Flask 本地开发服务器上运行应用程序有所不同?

Here's also the error that I have in my Browser console:这也是我在浏览器控制台中遇到的错误: 错误浏览器控制台

It's a Mixed Active Content issue.这是一个混合活动内容问题。 If you are viewing a site over HTTPS and it has some active content like <script> <iframe> or fetch() making a request to an HTTP endpoint, it will be blocked by default by the modern browsers.如果您正在查看超过 HTTPS 的站点并且它有一些活动内容,例如<script> <iframe>fetch()向 HTTP 端点发出请求,现代浏览器默认会阻止它。 On the locahost you are using HTTP, so it's not an issue.在本地主机上,您使用的是 HTTP,所以这不是问题。 So to fix the issue, change jQuery's src from http:// to https:// .因此,要解决此问题,请将 jQuery 的srchttp://更改为https://

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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