I'm trying to make a jquery Ajax call from an HTTPS website to an HTTP endpoint.
I'm getting a "Mixed Content" Error:
Mixed Content: The page at 'https://...' was loaded over HTTPS,
but requested an insecure XMLHttpRequest endpoint 'http://...'.
This request has been blocked; the content must be served over HTTPS.
The problem is that my callback on Ajax event 'complete' does not fire although according to the jquery page (https://api.jquery.com/Ajax_Events/):
complete (Local Event)
This event is called regardless of if the request was successful, or not.
You will always receive a complete callback, even for synchronous requests.
Here is my code:
$.ajax({
type: "POST",
url: url,
data: data,
complete: function (results) {
// Stuff in here is not executed on "Mixed Content" error
}
});
Is there any other way to catch the error? Ajax doesn't seem capable.
EDIT I am aware of this question: HTTP Ajax Request via HTTPS Page
My question is not "why is the error occuring", I'm expecting it to happen. My question is how can I catch that type of error since jQuery's 'complete' event fails.