简体   繁体   English

XMLHttpRequest无法检索json输出

[英]XMLHttpRequest cannot retrieve the json output

My goal is to get the json output of a Http "Get". 我的目标是获取Http“ Get”的json输出。 Then use this json output into D3. 然后使用此json输出到D3。

I created a httpGet function like follows, the settings are exact the same as my Postman, and I can get the json response in Postman. 我创建了如下的httpGet函数,其设置与Postman完全相同,并且可以在Postman中获取json响应。

function httpGet(theUrl)
{

    var xmlHttp = new XMLHttpRequest();
    xmlHttp.open( "GET", theUrl, true, "admin", "admin" );
    xmlHttp.setRequestHeader('Content-Type', 'application/json');
    xmlHttp.setRequestHeader('X-M2M-Origin', '//localhost:10000');
    xmlHttp.setRequestHeader('X-M2M-RI', '12345');
    xmlHttp.setRequestHeader('X-M2M-OT', 'NOW');
    xmlHttp.send();
    return "[" + xmlHttp.responseText + "]";
}



 var aaa = httpGet('localhost:8282/InCSE1/?rcn=4');

They are in the same domain. 它们在同一个域中。 In javascript, chrome tells me that: 在javascript中,chrome告诉我:

OPTIONS /localhost:8282/InCSE1/?rcn=4 httpGet @ (index):118update @ (index):105(anonymous function) @ (index):61t @ d3.v3.min.js:1(anonymous function) @ d3.v3.min.js:1t @ d3.v3.min.js:1u @ d3.v3.min.js:1 (index):1 XMLHttpRequest cannot load http://localhost:8282/InCSE1/?rcn=4 . 选项/ localhost:8282 / InCSE1 /?rcn = 4 httpGet @(索引):118update @(索引):105(匿名函数)@(索引):61t @ d3.v3.min.js:1(匿名函数)@ d3.v3.min.js:1t @ d3.v3.min.js:1u @ d3.v3.min.js:1(index):1 XMLHttpRequest无法加载http:// localhost:8282 / InCSE1 /?rcn = 4 Invalid HTTP status code 500! 无效的HTTP状态代码500!

http://i.stack.imgur.com/lWF4S.png http://i.stack.imgur.com/lWF4S.png

status code 500! 状态码500!

This means its a server error not a client side issue. 这意味着它是服务器错误,而不是客户端问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM