- Mon Oct 06, 2014 9:40 am
#1309
Ok. I tried with the XMLhttpRequest now...
But the console said:
XMLHttpRequest cannot load http://192.168.1.101:8000/. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access. I tried to send the response to the browser...
*** TERMINAL ****
AT+CIPSEND=0,200
HTTP/1.1 200 OK\r\nAccess-Control-Allow-Origin: "*"\r\nContent-Type: text/html\r\nHello world!\r\n
AT+CIPCLOSE=0
**********************
**** HTML ****
<!DOCTYPE HTML>
<html>
<head>
<script>
var xmlhttp;
function loadXMLDoc(){
if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function() {
console.log("readystate " + xmlhttp.readyState);
console.log("status " + xmlhttp.status);
console.log(xmlhttp.getAllResponseHeaders());
console.log(xmlhttp.responseText);
if (xmlhttp.readyState==4 && xmlhttp.status==200){
console.log(xmlhttp.responseText);
//document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","http://192.168.1.101:8000",true);
xmlhttp.send();
//console.log("status " + xmlhttp.status);
}
function send() {
xmlhttp.send("jooooo");
}
loadXMLDoc();
</script>
</head>
<body>
<div id="sse">
<a href="javascript:send()">Send</a>
</div>
</body>
</html>
**** / HTML ****