<html>
<body>
<h2>Click the Button.</h2>
<p>A script tag with a src attribute is created and placed in the document.</p>
<p>The PHP file returns a call to a function with the JSON object as a parameter.</p>
<button onclick="clickButton()">Click me!</button>
<p id="demo"></p>
<p>Try changing the table property from "customers" to "products".</p>
<script>
function clickButton() {
var obj, s
obj = { table: "customers", limit: 10 };
s = document.createElement("script");
s.src = "jsonp_demo_db52a0.json?x=" + JSON.stringify(obj);
document.body.appendChild(s);
}
function myFunc(myObj) {
var x, txt = "";
for (x in myObj) {
txt += myObj[x].name + "<br>";
}
document.getElementById("demo").innerHTML = txt;
}
</script>
</body>
<!-- Mirrored from www.w3schools.com/js/tryit.asp?filename=tryjson_jsonp_php by HTTrack Website Copier/3.x [XR&CO'2014], Mon, 27 Jan 2020 02:28:18 GMT -->
</html>