I've encountered an issue with JSONP. Although I was able to successfully load my JSONP data into my html file, I am struggling to display all the information. I have attempted using both a for loop and $.each method without any luck.
Here is the JSONP in the php file:
<?php echo $_GET["callback"] ?> (
{
"expo":"pit",
"datum":"05.06.2011 - 05.06.2016",
"img":"images/pit_home.jpg",
"link":"indexpit.html"
},
{
"expo":"Space Odessy 2.0",
"datum":"17.02 - 19.05.2013",
"img":"images/so_home.jpg",
"link":"indexso.html"
}
);
Below is the script used to call the JSONP:
<script type="text/javascript">
$.ajax({
type: 'GET',
jsonpCallback: 'jsonCallback',
contentType: 'application/json',
dataType: 'jsonp',
url: 'http://mllsdemode.be/Ex-cache/home.php',
success: function(json) {
for (var key in json) {
var el = document.getElementById("home");
el.innerHTML = "<li><a href=" + json.link + " data-ajax='false'><img src=" + json.img + "><div class='dsc'>" + json.expo + "<br><em>" + json.datum + "</em></div></a></li>";
}
},
error: function() { alert("Error reading JSONP file"); }
});
</script>
Does anyone have a solution on how to display all the information? Currently, only the data for pit is showing up, not for Space Odessy 2.0.