mirror of https://github.com/axmolengine/axmol.git
Fixed a bug that xhr cross-domain error
This commit is contained in:
parent
05c40b13f9
commit
82c09e8d0c
|
@ -104,10 +104,13 @@ var XHRTestLayer = cc.Layer.extend({
|
|||
// 5 seconds for timeout
|
||||
xhr.timeout = 5000;
|
||||
|
||||
xhr.setRequestHeader("Accept-Encoding","gzip,deflate");
|
||||
|
||||
//set arguments with <URL>?xxx=xxx&yyy=yyy
|
||||
xhr.open("GET", "http://geek.csdn.net/news/detail/33683", true);
|
||||
if(cc.sys.isNative){
|
||||
xhr.open("GET", "http://geek.csdn.net/news/detail/33683", true);
|
||||
xhr.setRequestHeader("Accept-Encoding","gzip,deflate");
|
||||
}else{
|
||||
xhr.open("GET", "http://httpbin.org/get?show_env=1", true);
|
||||
}
|
||||
|
||||
xhr.send();
|
||||
},
|
||||
|
@ -127,7 +130,7 @@ var XHRTestLayer = cc.Layer.extend({
|
|||
ensureLeftAligned(responseLabel);
|
||||
responseLabel.x = winSize.width / 10 * 3;
|
||||
responseLabel.y = winSize.height / 2;
|
||||
|
||||
|
||||
var xhr = cc.loader.getXMLHttpRequest();
|
||||
streamXHREventsToLabel(xhr, statusPostLabel, responseLabel, "POST");
|
||||
|
||||
|
|
Loading…
Reference in New Issue