0

I changed the database columns to be not nullable and not it works find. But still, no values are received. here is the console error: 4abdikani.local.ask.org/json.php:1 Failed to load resource: net::ERR_NAME_NOT_RESOLVED 4graphs.html:153 GET abdikani.local.ask.org/json.php net::ERR_NAME_NOT_RESOLVED – what will be the solution for such an error. The code answer for the question How to turn a json files into a graph? returns this error

Here is the main part of the code. I want it to return the value from the local php page and display it on a graph.

function getData() {
            var xhttp = new XMLHttpRequest();
            xhttp.onreadystatechange = function() {
                if (this.readyState == 4 && this.status == 200) {
                    //Push the data in array
                    var time = new Date().toLocaleTimeString();
                    var txt = this.responseText;
                    var obj = JSON.parse(txt); //Ref: https://www.w3schools.com/js/js_json_parse.asp
                    console.log(obj);
                    obj.forEach(function(element_data){
                        console.log(element_data);
                        ADCvalues.push(element_data.waterlevel);
                        Tvalues.push(element_data.temperature);
                        Hvalues.push(element_data.humidity);
                        timeStamp.push(time);
                        showGraph();
                        var table = document.getElementById("dataTable");
                        var row = table.insertRow(1); //Add after headings
                        var cell1 = row.insertCell(0);
                        var cell2 = row.insertCell(1);
                        var cell3 = row.insertCell(2);
                        var cell4 = row.insertCell(3);
                        cell1.innerHTML = time;
                        cell2.innerHTML = element_data.waterlevel;
                        cell3.innerHTML = element_data.temperature;
                        cell4.innerHTML = element_data.humidity;
                    });
                }
            };
            xhttp.open("GET", "http://abdikani.local.ask.org/json.php", true); // Works fine with me using the same json document locally - Handle readADC server on ESP8266
            xhttp.send();
        }
        </script>
    </body>
</html>
Monolica
  • 115
  • 7
  • 1
    Please post the exact code you were using inline in your question – HardcoreHenry Jun 25 '19 at 13:19
  • The code is on the other page, visit it please. – Monolica Jun 25 '19 at 13:30
  • 2
    People tend not to follow links, and by not inlining, you greatly decrease the number of people willing to help you. Having said that, I just followed the link, and you're refering to a very large piece of code, so I can see your hesitation in copying the entire thing. If you can, try to simplify it, and copy out any relevent bits. – HardcoreHenry Jun 25 '19 at 13:35
  • 1
    Here is the main code posted. – Monolica Jun 25 '19 at 13:40

0 Answers0