'Access-Control-Allow-Origin'标头包含多个值'null,*',但只允许一个

时间:2014-08-01 05:46:32

标签: javascript ajax http request

这是我的代码

<script>
function loadXMLDoc()
{
var xmlhttp;
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {

    var responseText = xmlhttp.status + xmlhttp.responseText; 
    document.getElementById("myDiv").innerHTML=responseText;   
  }
 xmlhttp.open("GET","https://exmaple.com/public/onDemandDemo/Products?$top=2");");
xmlhttp.send();
}

</script>

当我尝试执行GET请求时,我得到了 **

  

“XMLHttpRequest无法加载   https://https://exmaple.com/public/onDemandDemo/Products?$顶部= 2。   'Access-Control-Allow-Origin'标头包含多个值   'null,*',但只允许一个。因此,原因'null'不是   允许访问。“

**错误

但是当我在requestmaker.com中使用相同的url和标题时,我得到了回复

请帮忙,因为我是javascript和AJAX的新手。

0 个答案:

没有答案