在cocos2d-html5里面 怎么取异步请求 某个json链接 比如异步记录玩家的分数去请求一些信息 x/xx/xxx.json
var xhr = cc.loader.getXMLHttpRequest();
xhr.open("GET", "http://httpbin.org/get");
xhr.onreadystatechange = function () {
if (xhr.readyState == 4 && (xhr.status >= 200 && xhr.status <= 207)) {
var httpStatus = xhr.responseText;
var res = JSON.parse(httpStatus);
cc.log(res.origin);
}
};
xhr.send("test=ok");
```
还有post方法同上
非常感谢 我找了api貌似没有找到
官方API下载下来后 里面的samples里就有