0

I have to link to a database on a site but I get this error and I do not know what you mean "XMLHttpRequest cannot load http://apptablet.altervista.org/Prova.php. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access." This is the function that is performed in the load

function fo() {
alert("Ciao");
    httpreq = new XMLHttpRequest();
    httpreq.onreadystatechange = function () {
        if (httpreq.readyState == 4 && httpreq.status == 200) {
            if (rip == 0) {
                alert(httpreq.responseText.split('-')[0]);
                document.getElementById("temp").value = httpreq.responseText.split('-')[0];
                alert(httpreq.responseText.split('-')[1]);
                if (httpreq.responseText.split('-')[1] == 1) {
                    document.getElementById("OnOff").value = "ON";
                }
                else {
                    document.getElementById("OnOff").value = "OFF";
                }
                rip++;
            }
        }
    };
    httpreq.open("POST", "http://apptablet.altervista.org/Prova.php");
    httpreq.responseType = "text";
    httpreq.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    httpreq.send();
}
  • 1
    Possible duplicate of [Origin is not allowed by Access-Control-Allow-Origin](https://stackoverflow.com/questions/10143093/origin-is-not-allowed-by-access-control-allow-origin) – Chirag Ravindra Jun 21 '17 at 08:55
  • 3
    Syntax error on line 17. No seriously, look at http://stackoverflow.com/help/how-to-ask and edit your question. Think like you were one of us: How should we help you? We know 0 of your code. We have no idea what you've done. You have to provide us information is a propper way, otherwise noone can help you. – Twinfriends Jun 21 '17 at 08:55
  • 1
    You you access a domain which is different from the one you are on then the remote domain needs to set the `Access-Control-Allow-Origin: ` to indicate that they're allowing you to access them on behalf of some user. – apokryfos Jun 21 '17 at 08:56
  • Possible duplicate of [XmlHttpRequest error: Origin null is not allowed by Access-Control-Allow-Origin](https://stackoverflow.com/questions/3595515/xmlhttprequest-error-origin-null-is-not-allowed-by-access-control-allow-origin) – tinamou Jun 21 '17 at 09:39

0 Answers0