Following is the Java Script code i have.
//URL = http://dev.stage.com/restapi/vc/auth/sessions/login/
//parametersURL = user.login=******&user.password=******
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlHttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlHttp.open( "POST", URL, true );
xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlHttp.setRequestHeader("Content-length", parametersURL.length);
xmlHttp.setRequestHeader("Connection", "close");
xmlHttp.send(parametersURL);
xmlHttp.onreadystatechange = function() {//Call a function when the state changes.
if(xmlHttp.readyState == 4 && xmlHttp.status == 200) {
alert(xmlHttp.responseText);
return xmlHttp.responseXML;
}
}
When tested in IE8, i am getting the correct response in the alert box.
<response status="success"><value type="string">
uX-DjjZ2XrSB_GAfjSLTapOJvyvd2U9Y8MHsQzrvFeo.</value></response>
But when tested in Chrome and Firefox. The response is empty. When checked with FireBug the response is empty and in the XML I get the following error
XML Parsing Error: no element found Location: moz-nullprincipal:{9fc08684-36c5-42b2-
b641-e9400c6e627f} Line Number 1, Column 1:
Using Poster plugin in Firefox i can get the correct response.
Please, let me know what is the issue
It is the cross domain issue. Which is not handled correctly in IE and hence it worked. Use jsonp to make cross domain requests and it worked like a charm.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.