var xhr = new XMLHttpRequest();
xhr.open(“GET”, “http://www.yahoo.com”);
>
var that = this;
xhr.onreadystatechange = function() {
>
// cc.log( xhr.statusText);
cc.log( xhr.responseText);
>
}
it can get only one part of the home page of yahoo.com
Is it normal or there is any parameter can adjust the length of response html?
I change the code as
var xhr = new XMLHttpRequest();
>
xhr.open(“GET”, “http://www.yahoo.com”);
>
xhr.onreadystatechange = function() {
>
if (xhr.readyState 2 /* DONE */)
{ cc.log (xhr.status);
}
if (xhr.readyState 1 /* DONE */)
{ cc.log (xhr.status);
>
}
if (xhr.readyState 3 /* DONE */)
{ cc.log (xhr.status);
}
if (xhr.readyState 4 /* DONE */)
{ cc.log (xhr.status);
c.log(“length”+xhr.responseText);
}
}
>
xhr.send();
},
>
it displays
Cocos2d: JS: 4
Cocos2d: JS: 200
Cocos2d: JS: length:79596
rather than 1,2,3,4 status
and also only get one part of html rather than whole page
original page size of yahoo.com is 322030
Thanks for your feedback, I will check it.
James Chen wrote:
Thanks for your feedback, I will check it.
you welcome
it is ok for small size html(can get whole page)
but for a large size html, it always fail.
if I download a 2~3M binary file, it always reports
Cocos2d: completed
Cocos2d: response failed
Cocos2d: error buffer: connect() timed out!