The following page:
http://datao.zerezo.com/tot.html
fills itself with an XHR call to a CORS-enabled website (http://dbpedia.org/sparql).
That process works fine in (for example) Chrome.
But I get an error when I load this page in a WebView.
It seems the status of the XHR's response is 0, instead of 200 in Chrome.
Did I do something wrong?
PS: the source code for the webpage is:
<html>
<head>
<title>Simple Ajax Example</title>
<script language="Javascript">
var urlToReach = 'http://dbpedia.org/sparql';
function xmlhttpPost() {
var xmlHttpReq = false;
var self = this;
// Mozilla/Safari
if (window.XMLHttpRequest) {
self.xmlHttpReq = new XMLHttpRequest();
}
// IE
else if (window.ActiveXObject) {
self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
}
self.xmlHttpReq.open('GET', urlToReach, true);
self.xmlHttpReq.onreadystatechange = function() {
if (self.xmlHttpReq.readyState == 4) {
if(self.xmlHttpReq.status == 200)
updatepage(self.xmlHttpReq.responseText);
else
updatepage('self.xmlHttpReq.status is '+self.xmlHttpReq.status+', sorry. Unable to get data back from '+urlToReach);
}
}
self.xmlHttpReq.send();
}
function updatepage(str){
document.getElementById("result").innerHTML = str;
}
</script>
</head>
<body onload="xmlhttpPost()">
<div id="result">the result will appear here</div>
</form>
</body>
</html>
http://datao.zerezo.com/tot.html
fills itself with an XHR call to a CORS-enabled website (http://dbpedia.org/sparql).
That process works fine in (for example) Chrome.
But I get an error when I load this page in a WebView.
It seems the status of the XHR's response is 0, instead of 200 in Chrome.
Did I do something wrong?
PS: the source code for the webpage is:
<html>
<head>
<title>Simple Ajax Example</title>
<script language="Javascript">
var urlToReach = 'http://dbpedia.org/sparql';
function xmlhttpPost() {
var xmlHttpReq = false;
var self = this;
// Mozilla/Safari
if (window.XMLHttpRequest) {
self.xmlHttpReq = new XMLHttpRequest();
}
// IE
else if (window.ActiveXObject) {
self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
}
self.xmlHttpReq.open('GET', urlToReach, true);
self.xmlHttpReq.onreadystatechange = function() {
if (self.xmlHttpReq.readyState == 4) {
if(self.xmlHttpReq.status == 200)
updatepage(self.xmlHttpReq.responseText);
else
updatepage('self.xmlHttpReq.status is '+self.xmlHttpReq.status+', sorry. Unable to get data back from '+urlToReach);
}
}
self.xmlHttpReq.send();
}
function updatepage(str){
document.getElementById("result").innerHTML = str;
}
</script>
</head>
<body onload="xmlhttpPost()">
<div id="result">the result will appear here</div>
</form>
</body>
</html>