php - 执行javascript代码时出现错误
问题描述
我将数据库列更改为不可为空,并且无法找到。但是,仍然没有收到任何值。这是控制台错误: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 –
此类错误的解决方案是什么。问题的代码答案如何将 json 文件转换为图形?返回此错误
这是代码的主要部分。我希望它从本地 php 页面返回值并将其显示在图表上。
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>
解决方案
推荐阅读
- angular - Angular 6:组件内的表单,单击提交按钮时未触发ngSubmit
- javascript - 如何使用javascript附加到id javascript变量中
- regex - RegEx 使用 PowerShell 在字符串中查找数字
- ecmascript-6 - ES6 模块导出和导入
- testing - 带有ecto的CRDB,在测试时,它不会从初始值开始序列
- macos - OSX Mojave 上的 GDB 兼容性问题
- qt - 如何更新 Qt ui 以从相机显示 opencv mat;
- windows-10 - 如何修复 secpol.msc 的 samba 共享连接问题?
- android - Uri.java 第 475 行 android.net.Uri$StringUri。
com.google.android.gms.ads - neo4j - Neo4j Desktop 1.1.10 如何导出密码文件?