0
votes

I know that something is calling over http instead of https, but actually I don't know how to fix this issue!

$.ajax({
    type: "GET",
    url: window.location.href.substring(0, location.href.lastIndexOf("/") + 1) + '/MyService.asmx/MyMethod';,
    data: 'param=' + JSON.stringify({ "myParam": value.trim() });,
    dataType: "text",
    error: function (XMLHttpRequest, textStatus, errorThrown) {
        alert("Request: " + XMLHttpRequest.toString() + "\n\nStatus: " + textStatus + "\n\nError: " + errorThrown);
    }, ...

I even tried this way but no success:

Url: '//MyService.asmx/MyMethod';

Given error is: Mixed Content: The page at 'https://www.example.com/MyPage.aspx' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://www.example.com/MyService.asmx?param=paramValue'. This request has been blocked; the content must be served over HTTPS.

Any suggestion?

1

1 Answers

0
votes

There are several things that might trigger this error.

First of all, change the javascript that construts your url to

window.location.href.substring(0, location.href.lastIndexOf("/") + 1) + 'MyService.asmx/MyMethod'

(remove slash before MyService.asmx and the semicolon at the end)

Try to console.log() the url this code produce and try if it's accessible via HTTPS in your browser. What might be happening is that if the url is unreachable there might be a redirect to non-https url. Also you can use browser debug tools (like chrome inspect Network tab) to see what's happening with your request (look for status code, check the response headers etc.).