Access is denied. Javascript error on request to secured page

Posted by ihorko on Stack Overflow See other posts from Stack Overflow or by ihorko
Published on 2011-02-03T15:14:23Z Indexed on 2011/02/03 15:25 UTC
Read the original article Hit count: 172

Filed under:
|
|
|

On SomePage.aspx page by javascript (XMLHttpRequest) I call SecuredPage.aspx used next code:

var httpRequest = GetXmlHttp();
var url = "https://myhost.com/SecuredPage.aspx";

    var params = "param1=" + document.getElementById('param1').value +
                "&param2=" + document.getElementById('param2').value;

    httpRequest.open("POST", url, true);
    httpRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");


    httpRequest.onreadystatechange = function() {
        //Call a function when the state changes.
        if (httpRequest.readyState == 4 && httpRequest.status == 200) {
            alert(httpRequest.responseText);
        }
    }
    httpRequest.send(params); // HERE ACCESS IS DENIED

//---------------------------------------------
    function GetXmlHttp() {
        var xmlhttp = false;
        if (window.XMLHttpRequest) {
            xmlhttp = new XMLHttpRequest();
        }
        else if (window.ActiveXObject)
        // code for IE
        {
            try {
                xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
            }
            catch (e) {
                try {
                    xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (E) {
                    xmlhttp = false;
                }
            }
        }
        return xmlhttp;
    }

It throws Access is denied error. if send to http (http://myhost.com/SecuredPage.aspx), it works fine.

How is it possible to resolve that problem.

Thanks!

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about AJAX