Permission denied When using access to XMLHttpRequest.Open cross browser

I am trying to access the XMLHTTPRequest.open method. I even included netscape.security.PrivilegeManager.enablePrivilege ("UniversalBrowserRead");

but still not working.

I use javascript and HTML to access the WebService.

Any help would be really wonderful

code



<html> <Head> <Title>Calling A WebService from HTML </Title> </Head>

<Body onload='GetDataFrmWS()'> <form name="Form1" id="Form1" runat="server" method="post"> <div id="DisplayData" > </div> <div id="Menu2"></div>

</form>

<script language='javascript'>

var objHttp; var objXmlDoc;

function GetDataFrmWS() { alert('IM Here'); var func = getDataFromWS();

}

function getDataFromWS() {

if(window.ActiveXObject) { try { objHttp = new ActiveXObject('Msxml2.XMLHTTP');

  } catch (ex) { objHttp = new ActiveXObject('Microsoft.XMLHTTP'); } 

} else if (window.XMLHttpRequest) { objHttp = .XMLHttpRequest(); netscape.security.PrivilegeManager.enablePrivilege( "UniversalBrowserRead" ); }

strEnvelope = '< soap: Envelope xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance" xmlns: xsd = "http://www.w3.org/2001/XMLSchema" xmlns: soap = "http://schemas.xmlsoap.org/soap/envelope/" > ' + '& ; : >' + '< HelloWorld xmlns = "http://tempuri.org/" >' + '< Dummy xsi: type = "xsd: string" > Hello </Dummy>' + '</HelloWorld>' + '& ;/: >' + '& ;/: >';

var szUrl; szUrl = ' http://kamadhenu/Quoteme/GetCategories.asmx?op=HelloWorld '; objHttp.onreadystatechange = HandleResponse;

objHttp.open('POST', szUrl, true); objHttp.setRequestHeader('Content-Type', 'text/xml'); objHttp.setRequestHeader('SOAPAction', ' http://tempuri.org/HelloWorld '); objHttp.send(strEnvelope);

}

HandleResponse() {
if (objHttp.readyState == 4) {

if (window.ActiveXObject) { objXmlDoc = ActiveXObject ( "Microsoft.XMLDOM" ); objXmlDoc.async = ""; objXmlDoc.loadXML(objHttp.responseText); var nodeSelect = objXmlDoc.getElementsByTagName( "Menu1" ). item (0); var Menu2 = objXmlDoc.getElementsByTagName( "2" ). item (0); document.getElementById( 'DisplayData') innerHTML = nodeSelect.text;.
document.getElementById( 'menu2') innerHTML = Menu2.text. } { var Text = objHttp.responseText; var parser = new DOMParser(); objXmlDoc = parser.parseFromString(, /xml ); var Value = objXmlDoc.documentElement.childNodes [0].childNodes [0].childNodes [0].childNodes [0].childNodes [0].childNodes [0].childNodes [0].nodeValue; var Menu2 = objXmlDoc.documentElement.childNodes [0].childNodes [0].childNodes [0].childNodes [0].childNodes [0].childNodes [1].childNodes [0].nodeValue; var Menu3 = objXmlDoc.documentElement.childNodes [0].childNodes [0].childNodes [0].childNodes [0].childNodes [0].childNodes [1].childNodes [1].nodeValue; document.getElementById( 'DisplayData') innerHTML = ;.
document.getElementById( 'menu2') innerHTML = menu2. document.getElementById( 'menu2') innerHTML + = menu3. } }

}

</script > < input type='Button' = 'Click Me' onclick = 'GetDataFrmWS()' value = "Click Me!" /></; </ > </HTML>

code>
+4
source share
4 answers

Browser Independent Code for XML HTTPRequest

I am using the following code to create an XML object. It was designed to handle all browsers (especially IE and not IE).

 /* Function to create an XMLHTTP object for all browsers */ function getXMLHTTPObject(){ 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){ alert("Your browser does not support AJAX!"); return false; } } } return xmlHttp; } /* End Function */ 

PS The code in the question is not readable. Format pls

+2
source

Here is a pretty brief example here

Try making your URL http://recpushdata.cyndigo.com/Jobs.asmx/InsertXML

PS. Your code is unreadable in StackOverflow.

+1
source

As far as I know, an XMLHTTP request should point to a page in the same subdomain of the html page for different browser resolutions.

One trick is to make another page on the same server in your preferred language and force the request to be processed using the serverโ€™s network.

Example:

from your HTML page, you make an ajax request at mydomain.com/externalrequest.php?url=www.google.com. and this page will connect (fsock / cURL, etc.) to url and return it

+1
source

If you are trying to cross-domain with XHR, you can learn the JSONP method. Check out jQuery docs for this.

It takes you to accept a JSON response, but it works across domains.

+1
source

All Articles