I have a little webserver on a microcontroller/WIFI module. Then I create on my PC an HTML file which is a simple button on a page (code below) to send a GET request over the internet to my server via Ajax using a browser. When I click the "SEND" button, I can see the entire HTTP request that arrived to the board and shows that all on the screen via serial port. So the microcontroller gives the following response:
HTTP/1.1 200 OK Content-Type: application/json {"fixedNotice":"9"}
The last line is the text of the response, I am trying to show this response on text input, but it's not working, the browser seems to be not receiving any reply to the request. And I am looking at the serial port terminal and the response is being given...
<!DOCTYPE html>
<html>
<head>
<title>BUTTON OVER INTERNET TEST</title>
<meta charset="UTF-8"/>
</head>
<body>
<input type="text" id="result" size="50">
<input type="button" onclick="Send()" value="SEND">
<script>
function Send()
{
var XHR = new XMLHttpRequest();
XHR.open("GET", "http://181.148.227.41:8383/internet_test", true);
XHR.onreadystatechange = function()
{
if (this.readyState == 4 && this.status == 200)
{
document.getElementById("result").value = this.responseText;
return;
}
};
XHR.send();
}
</script>
</body>
</html>
Why I am not receiving the response for the Ajax/GET request? Is that something related to CORS? That IP shown is fake.