JavaScript
jQuery
JSON
index.html #
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<script src='//cdnjs.cloudflare.com/ajax/libs/jquery/2.2.4/jquery.min.js'></script>
</head>
<body>
<!-- https://www.sitepoint.com/jsonp-examples/ -->
<div style="background: goldenrod; padding: 1rem;">
<script src="http://lab.rjwebdesign.cz/jsonp/js.php"></script>
</div>
<div style="background: burlywood; padding: 1rem;" id="jsonp">
</div>
<script>
// 1 zpusob
$.getJSON('http://lab.rjwebdesign.cz/jsonp/jsonp.php?callback=?', function(json){
console.log(json);
});
// 2 zpusob
function logResults(json) {
console.log(json);
}
$.ajax({
url: "http://lab.rjwebdesign.cz/jsonp/jsonp.php",
dataType: "jsonp",
jsonpCallback: "logResults"
});
</script>
</body>
</html>