admin管理员组文章数量:1426325
I am facing problem that whenever I turn off security settings in IE8, in my application, xmlHTTPRequest call is failed.However when I turn it on, its working fine. The security feature is : Tools -> Internet Options -> Advance -> security -> Enable Native xmlHTTP support. If it is checked then no problem occurs but in case if it is not checked, the xmlHTTPReq fails to send request to server.(I don't see the cgi call in debugger window).
So my question is : is it possible to detect that this security settings is enabled or not using JavaScript programatically ?
My code for cgi call is as under :
try{
var xmlHttpReq;
var destinationURL = cgiBinPath+"helloworld.cgi?start";
// IE 7+, Mozilla/Safari
if (window.XMLHttpRequest) {
xmlHttpReq=new XMLHttpRequest();
}
//IE 5,6
else {
xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
}
if (xmlHttpReq.readyState == 0){
xmlHttpReq.open('GET', destinationURL, true);
xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xmlHttpReq.onreadystatechange = function(){
if(xmlHttpReq.readyState == 4){
//Control never reaches here
}
}
xmlHttpReq.send();
}
}catch(e){
alert('Exception '+e);
}
I am facing problem that whenever I turn off security settings in IE8, in my application, xmlHTTPRequest call is failed.However when I turn it on, its working fine. The security feature is : Tools -> Internet Options -> Advance -> security -> Enable Native xmlHTTP support. If it is checked then no problem occurs but in case if it is not checked, the xmlHTTPReq fails to send request to server.(I don't see the cgi call in debugger window).
So my question is : is it possible to detect that this security settings is enabled or not using JavaScript programatically ?
My code for cgi call is as under :
try{
var xmlHttpReq;
var destinationURL = cgiBinPath+"helloworld.cgi?start";
// IE 7+, Mozilla/Safari
if (window.XMLHttpRequest) {
xmlHttpReq=new XMLHttpRequest();
}
//IE 5,6
else {
xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
}
if (xmlHttpReq.readyState == 0){
xmlHttpReq.open('GET', destinationURL, true);
xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xmlHttpReq.onreadystatechange = function(){
if(xmlHttpReq.readyState == 4){
//Control never reaches here
}
}
xmlHttpReq.send();
}
}catch(e){
alert('Exception '+e);
}
Share
Improve this question
asked Nov 1, 2011 at 9:18
VedVed
8,7777 gold badges38 silver badges69 bronze badges
1
- No sane person disables this setting – ThiefMaster Commented Nov 1, 2011 at 9:23
1 Answer
Reset to default 2Take a look at this article about native XMLHTTP on MSDN. It also provides a solution for your problem.
Edit
I'm sorry, I didn't read the article carefully enough... This one will answer your question. You will have to try if you can create an instance of the XMLHttpRequest
object.
if (window.XMLHttpRequest) {
try {
xmlHttpReq = new XMLHttpRequest();
} catch (ex) {
xmlHttpReq = new window.ActiveXObject("Microsoft.XMLHTTP");
}
} else {
//...
}
本文标签: IE 8 security settings prevents javascript to send xmlHTTPRequestStack Overflow
版权声明:本文标题:IE 8 security settings prevents javascript to send xmlHTTPRequest - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745466032a2659538.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论