问题
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