简体   繁体   English

强制AJAX调用从HTTPS页面成为HTTPS

[英]Forcing AJAX call to be HTTPS from HTTPS Page

Currently making an AJAX call from a HTTPS jsp to call in data from another jsp page. 目前正在从HTTPS jsp进行AJAX调用以从另一个jsp页面调用数据。 We are however getting a Mixed content issue: 然而,我们遇到了混合内容问题:

Mixed Content: The page at ' https://etc/ ' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint ' http://etc/path/to/other/page.jsp '. 混合内容:“ https:// etc / ”页面是通过HTTPS加载的,但是请求了一个不安全的XMLHttpRequest端点“ http://etc/path/to/other/page.jsp ”。 This request has been blocked; 此请求已被阻止; the content must be served over HTTPS. 内容必须通过HTTPS提供。

How do you force an AJAX call to call over HTTPS? 你如何强制通过HTTPS调用AJAX调用?

The AJAX call looks like the following: AJAX调用如下所示:

var url = "/path/to/other/page.jsp";

$.ajax({                                                            
    type: "POST",
    url: url,
    data: {data: data},
    dataType: "html",
    timeout: 4000, 
    success: function(html) {
        /* Code on Success */
        }
    },
    error: function(request, status, error) {
         /* Code on Failure
    }   
});

I could understand if I was trying to make a call from HTTPS to HTTP, but I don't want to. 我能理解我是否正在尝试从HTTPS到HTTP进行呼叫,但我不想这样做。 I want to force this to call the JSP using HTTPS is all, so I can avoid the Mixed Content issue. 我想强迫它使用HTTPS调用JSP,所以我可以避免混合内容问题。

Thank you in advance! 先感谢您!

/* EDIT */ / *编辑* /

Interestingly I put in the variable URL an absolute path: 有趣的是,我在变量URL中输入了一个绝对路径:

var url = "https://etc/path/to/other/page.jsp";

And I got the same issue. 我也遇到了同样的问题。 Something is forcing this AJAX call to be HTTP? 有什么东西迫使这个AJAX调用成为HTTP?

尝试使用其他扩展程序或像.htaccess等使用像这样的文件夹

 var url = "https://etc/path/to/other/page/"; 

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

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