How to get XMLHttpRequest to work on HTTPS on Firefox?

When I try to send an HTTP GET request via XMLHttpRequest, it works with insecure HTTP.

But when sending via HTTPS, different browsers gave different results:

In Firefox 3.0.2: - GET request does not reach the web server.

In IE 7: - The GET request reached the web server.

Is this because Firefox 3 is becoming more stringent with untrusted certificates? Is there any way around this?

I already added the URL as an exception in Firefox Certificate Manager. The error console does not report an error. I added try-catch around XMLHttpRequest open () and submit. No exception selected.

Using an absolute and relative URL path does not work.

Here's the code snippet:

    var xmlHttp;
    try
    {
        // Firefox, Opera 8.0+, Safari
        xmlHttp=new XMLHttpRequest();
    }
    catch (e)
    {
        // Internet Explorer
        try
        {
            xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e)
        {
            try
            {
                xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch (e)
            {
                return false;
            }
        }
    }
    // we won't be handling any HTTP response
    xmlHttp.onreadystatechange=function()
    {
        // do nothing..
    }
    // send HTTP GET request
    try
    {
        xmlHttp.open("GET", "/[relative path to request]", true);
        xmlHttp.send(null);
    }
    catch (e)
    {
        alert('Error sending HTTP GET request!');
        return false;
    }

Thanks Kenneth

+3
source share
2

:

// send HTTP GET request
try
{
    xmlHttp.open("GET", "/[relative path to request]", true);
}
catch (e)
{
    alert('Error sending HTTP GET request!');
    return false;
}
// we won't be handling any HTTP response
xmlHttp.onreadystatechange=function()
{
    // do nothing..
}

// Then send it.
xmlHttp.send(null);

: http://www.ghastlyfop.com/blog/2007/01/onreadystate-changes-in-firefox.html

.send(null), .

+1

URL-, HTTPS, HTTPS? - /?

0

Source: https://habr.com/ru/post/1697557/


All Articles