jQuery AJAX Request to HTTPS getting served to HTTP with Laravel and Select2

家住魔仙堡 提交于 2019-12-24 17:46:03

问题


I have a relatively simple Laravel app, that features an HTML form which contains a tag select element. The select element gets enhanced via select2 library. The tags are fetched via an XMLHttpRequest. I've created a fiddle, and the error I receive there is the same as on my production machine:

[...]was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://blog.mazedlx.net/tags?term=asd'. This request has been blocked; the content must be served over HTTPS.

$('#tags_id').select2({
    minimumInputLength: 2,
    tags: true,
    tokenSeparators: [','],
    ajax: {
        url: 'https://blog.mazedlx.net/tags/',
        type: 'GET',
        dataType: 'json',
        data: function (params) {
            var queryParameters = {
                term: params.term
            }
            return queryParameters;
        },
        processResults: function (data) {
            return {
                results: $.map(data, function (item) {
                    return {
                        text: item.tag,
                        id: item.id
                    };
                })
            };
        }
    }
});

As you can see in the fiddle the ajax url contains https, and the page containing the form is also served over https. The url also yields results: e.g. https://blog.mazedlx.net/tags?term=php. What am I doing wrong?


回答1:


Solved it. Needed to modify my Apache conf for that vhost. The SSL directives where only loaded for the main domain, but not for that subdomain.



来源:https://stackoverflow.com/questions/36008995/jquery-ajax-request-to-https-getting-served-to-http-with-laravel-and-select2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!