Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 已解析/未解析Chrome和IE的JSON响应_Javascript_Json_Google Chrome_Xmlhttprequest_Internet Explorer 11 - Fatal编程技术网

Javascript 已解析/未解析Chrome和IE的JSON响应

Javascript 已解析/未解析Chrome和IE的JSON响应,javascript,json,google-chrome,xmlhttprequest,internet-explorer-11,Javascript,Json,Google Chrome,Xmlhttprequest,Internet Explorer 11,XMLhttpRequest返回带有 abc.responseType='json' var-answer=abc.response 如果我执行以下操作,它将在chrome中工作: if (answer.success) { window.alert("GOODBOY!"); } else { window.alert("YOUFAILED" + answer.message); } 然而,即使成功为真 为了让它在InternetExpl

XMLhttpRequest返回带有

abc.responseType='json'

var-answer=abc.response

如果我执行以下操作,它将在chrome中工作:

if (answer.success) {
        window.alert("GOODBOY!");
      } else {
        window.alert("YOUFAILED" + answer.message);
      }
然而,即使
成功
为了让它在InternetExplorer中工作,我尝试(再次)解析它

这在IE中起作用,但在chrome中明显导致以下错误:

Uncaught SyntaxError:JSON中位置1处的意外标记o


我错过了什么?如何使其在两种浏览器上都工作?

由于IE不支持
json
作为
响应类型,请删除该选项,使用默认的
文本
,然后执行以下操作

 var answer = JSON.parse(abc.response);

由于IE不支持将
json
作为
responseType
,请删除该选项,使用默认的
文本
,然后执行以下操作

 var answer = JSON.parse(abc.response);

您可以使用
JSON.stringify(abc,0,4)打印
abc
的值吗并检查?您可以使用
JSON.stringify(abc,0,4)打印
abc
的值吗并检查?这很简单-谢谢我会在允许的情况下尽快标记你的答案这很简单-谢谢我会在允许的情况下尽快标记你的答案