Forcing AJAX call to be HTTPS from HTTPS Page

心已入冬 提交于 2020-01-01 04:25:28

问题


Currently making an AJAX call from a HTTPS jsp to call in data from another jsp page. 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'. This request has been blocked; the content must be served over HTTPS.

How do you force an AJAX call to call over HTTPS?

The AJAX call looks like the following:

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. I want to force this to call the JSP using HTTPS is all, so I can avoid the Mixed Content issue.

Thank you in advance!

/* EDIT */

Interestingly I put in the variable URL an absolute path:

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

And I got the same issue. Something is forcing this AJAX call to be HTTP?


回答1:


Try use another extension or use like folder with .htaccess etc. like this

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


来源:https://stackoverflow.com/questions/28277443/forcing-ajax-call-to-be-https-from-https-page

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