XMLHttpRequest 请求出现错误怎么办 求大神啊

代码
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function () {
if (xhr.readyState == 4 && (xhr.status >= 200 && xhr.status < 400)) {
var response = xhr.responseText;
console.log(“网络请求” + response);
}
};
xhr.open(“GET”, “http://127.0.0.1/storybook/public/server/test/12345”, true);
xhr.send();

出现下面错误求大神啊!
Simulator : In the constructor of HttpClient!
Simulator : Response failed, error buffer: The resource could not be loaded because the App Transport Security policy requires the use of a secure connection.

iOS9引入了新特性App Transport Security,要求App内访问的网络必须使用HTTPS协议。
如果没有使用HTTPS协议的话,也可以在xcode里面设置

  1. 在Info.plist中添加NSAppTransportSecurity 类型Dictionary。
  2. 在NSAppTransportSecurity下添加NSAllowsArbitraryLoads 类型Boolean,值为YES
2赞

楼上正解,参考:

http://stackoverflow.com/questions/30731785/how-do-i-load-an-http-url-with-app-transport-security-enabled-in-ios-9

你好,不好意思啊我提问错了,不是ios啊, 我用的是Mac 用Cocos Creator 模拟器 出现这个错误
Simulator : In the constructor of HttpClient!
Simulator : Response failed, error buffer: The resource could not be loaded because the App Transport Security policy requires the use of a secure connection.
真的不知道怎么做了求教呀?

我也遇到这个问题,你的解决了吗?

没有啊 怎么办啊 求解决

多谢 一楼 正解我的问题 前天么有理解,现在自己想想理解了 弄好了 多谢多谢
方法:
Mac Cocos Creator 虚拟机 不能访问网络的情况需要设置
/Applications/CocosCreator.app/Contents/Resources/cocos2d-x/simulator/mac/Simulator.app/Contents/Resources/
这个目录下面的 info.plist

  1. 在Info.plist中添加NSAppTransportSecurity 类型Dictionary。
    2.App Transport Security,类型Boolean,值为YES
1赞

谢谢你提供的目录,你好像多写了一级:/Applications/CocosCreator.app/Contents/Resources/cocos2d-x/simulator/mac/Simulator.app/Contents,我这是把CocosCreator删除后重装这么修改才起的作用。

我遇到同一个问题,但我在info.plist改了后,我就无法在CocosCreator打开模拟器了,请问是什么问题导致的?