使用SSL https请求时xml失败

时间:2015-02-28 16:08:34

标签: javascript xml perl

我使用以下javascript在使用http时工作正常,但不是IE 11中的https。

<script type="text/javascript">
 function checkloginform() {
   if (window.XMLHttpRequest) {
       xmlhttp=new XMLHttpRequest(); // code for IE7+, Firefox, Chrome, Opera, Safari
   } else {
       xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); // code for IE6, IE5
   }
   xmlhttp.onreadystatechange=function() {
     if (xmlhttp.readyState==4 && xmlhttp.status==200) {
         var y = xmlhttp.responseText;
         document.getElementById("memo").innerHTML = y;
     } else {
         document.getElementById("memo").innerHTML =
          'Error: '+ xmlhttp.readyState + ' ' + xmlhttp.status;
     }
   }
   xmlhttp.open("GET","/test/test.pl",true);
   xmlhttp.send();
 }
</script>

如果我改变

xmlhttp.open("GET","/test/test.pl",true);

xmlhttp.open("GET","https://www.website.com/test/test.pl",true);

我什么也没收到,没有状态错误?

如果我直接从同一个浏览器访问该URL,它会返回预期的输出。

这是服务器端test.pl

#!/usr/bin/perl

MAIN:
{
 print qq~content-type: text/xml\n\nTEST\n ~;
 exit;
}

1 个答案:

答案 0 :(得分:0)

这是跨域问题。我通过http @ xyz.com加载了网站并切换到https @ 123.com。