Code has been added to clipboard!
Use of HTTP POST With PHP json_decode
Example
obj = { "table":"customers", "limit":10 };
dbParam = JSON.stringify(obj);
xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
newObj = JSON.parse(this.responseText);
for (x in newObj) {
txt += newObj[x].name + "<br>";
}
document.getElementById("JSON").innerHTML = txt;
}
};
xmlhttp.open("POST", "JSON.php", true);
xmlhttp.setRequestHeader("Content-type", "application/learn-encoded");
xmlhttp.send("x=" + dbParam);