gpt4 book ai didi

javascript - AJAX 使用 HTTP 而不是 HTTPS

转载 作者:搜寻专家 更新时间:2023-11-01 04:40:58 25 4
gpt4 key购买 nike

我的 AJAX 请求正在使用 HTTP,即使该请求源自使用 HTTPS 的页面。知道为什么要降级为 HTTP 吗?

这是我的 AJAX 请求:

$(function() {

// Update section options whne course is changed
$('#id_new_course').change(function() {

// Get selected coursenum
var val = $(this).val();
var sect_input = $('#id_section');

// Disable #id_section when no course is selected
if (val == '') {
sect_input.empty();
sect_input.prop('disabled', true);
} else {
// Get list of sections for selected course and update #id_section options
$.ajax({
url: '/account/support_dashboard.get_course_sections/' + val + '/',
dataType: 'json',
success: function(data) {
// Empty options and add new ones to #id_section
sect_input.empty();
$.each(data, function(value, key) {
sect_input.append($('<option></option>').attr('value', value).text(key));
});
sect_input.prop('disabled', false);
},
error: function() {
console.log('ERROR OCCURRED TRY AGAIN');
}
});//ajax
}//if

});

}); //ready

这是我的网络控制台中的错误输出:

Mixed Content: The page at 'https://www.myeducator.com/account/support_dashboard/1027/993532704604577793/' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://www.myeducator.com/account/support_dashboard.get_course_sections/915ba/'. This request has been blocked; the content must be served over HTTPS.

正在通过 HTTPS 加载 javascript 文件:

Request Over HTTPS

此外,实际的 ajax 请求是作为 HTTPS 发出的:

AJAX Request over HTTPS

我也不认为它与我的网络服务器 (nginx) 有任何关系。我只有一个重写命令,使用相同的请求方案将任何未处理的子域重定向到 www.myeducator.com:

server {
listen 443 default_server ssl;
server_name _;

...

# the rewrite string
rewrite ^ $scheme://www.myeducator.com$request_uri redirect;
}

最佳答案

我也遇到过类似的问题,很费解...

Mixed Content: The page at 'https://domain.com/blah.json' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://domain.com'. This request has been blocked; the content must be served over HTTPS.

原来是 .json 没有在 IIS 的 MIME 类型中设置。添加 .json 扩展名后,一切正常。

编辑:我怀疑你的端点“dashboard.get_course_sections”有一个点,它让你的服务器认为这是一个它不支持的资源。

关于javascript - AJAX 使用 HTTP 而不是 HTTPS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30715983/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com