如何修复“使用ajax重定向的symfony中的混合内容错误”

时间:2019-03-25 13:35:08

标签: ajax symfony-3.4 mixed-content

在这里,我有两种形式。第一个允许患者在没有帐户来完成任命时进行注册;另一个允许患者在已经有标识符的情况下使用其标识符进行连接。在两种情况下,当单击按钮发送连接或注册表格时,我的按钮均不会激活。这向我显示了控制台中的错误:“混合内容:'https://doctix.net/booking/confirm?idMedecin=70&time=09:30&date=26-03-2019'上的页面已通过HTTPS加载,但请求了不安全的XMLHttpRequest端点'http://doctix.net/'。此请求已被阻止;内容必须通过HTTPS提供。”。请注意,当我在localhost时,我的代码可以工作,但是当我切换到生产环境时,它会告诉我这个错误

我的树枝

    <div class="col-md-offset-3 col-md-12 col-lg-12 is-masque" id="authenticationForm">
                    <div class="panel panel-info">
                        <div class="panel-heading">
                            <div class="page-header">
                                <p>

                                <h2 class="text-center">Authentification</h2>

                                </p>
                            </div>

                        </div>
                        <div class="panel-body">
                            <form id="bookingForm" method="POST" action="{{ path('login_check') }}">

                                <label for="text">Email</label>
                                <div class="row">
                                    <div class="col-md-offset-3 col-md-12 col-lg-12">
                                        <input type="email" name="_username" value="" id="utilisateur" class="form-control" tabindex="1" required placeholder="Entrez votre email" autofocus> <br/>
                                    </div>
                                </div>

                                <label for="text">Mot de passe</label>
                                <div class="row">

                                    <div class="col-md-offset-3 col-md-12 col-lg-12">
                                        <input type="password" name="_password" id="keyword" class="form-control" tabindex="2" required placeholder=" Entrez votre mot de passe" > <br/>

                                    </div>
                                </div>
                            </form>
                        </div>

                        <div class="panel-footer text-center">
                              <button type="reset" class="btn btn-warning  pull-right"  form="bookingForm">Annuler</button>

                               <button type="submit" class="btn btn-success" name="connexion"  form="bookingForm">Connexion</button>

                        </div>

                    </div>
                </div>

我与Ajax的重定向

   $(document).ready(function(){

     $('#bookingForm').submit(function(event) {
    event.preventDefault();
    // appel Ajax
    $.ajax({
        url: $(this).attr('action'), // le nom du fichier indiqué dans le formulaire
        type: $(this).attr('method'), // la méthode indiquée dans le formulaire (get ou post),
        data: {'_username': $('#utilisateur').val(), '_password': $('#keyword').val()}, 
        cache: false,
        success: function(data) { 
            urlParams = new URLSearchParams(window.location.search)
            medecin = urlParams.get('idMedecin');
            time = urlParams.get('time');
            date = urlParams.get('date');

            window.location.href = "/patient/booking?idMedecin="+medecin+"&time="+time+"&date="+date;
    }       
    });
});
   });

预期结果是登录按钮将我重定向到ajax的window.location.href中指定的页面

0 个答案:

没有答案