Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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. 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?

like image 791
KirisuteRanza Avatar asked Feb 02 '15 12:02

KirisuteRanza


1 Answers

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

var url = "https://etc/path/to/other/page/";
like image 70
Josephy Besim Avatar answered Oct 23 '22 20:10

Josephy Besim