This site is mobile accessible. Press the "Tap Here" button to use a different font-size.


Smartphone icons created by Freepik - Flaticon

Request JSON using the script tag

The PHP file returns a call to a function that will handle the JSON data.

function myFunc(myObj) {
  document.getElementById("demo").innerHTML = myObj.name;
}

<script src="include/PHP/demo_jsonp.php"></script>
<?php
$myJSON = '{ "name":"John", "age":30, "city":"New York" }';

echo "myFunc(".$myJSON.");";
?>