I have to read and display json formatted results in my app. I am forced to use JSONP at client side due to same origin policy. But it displays null
Please let me know where I am going wrong and it displays null. Any help is appreciated
PHP code at server side
while ($r = mysql_fetch_assoc($result))
{
$rows[] = $r;
}
echo json_encode($rows);
JSON output I receive from PHP code above
[
{
"a_name": "affles",
"bname": "bua",
"c_number": "10101010",
"dateandtime": "2013-11-30 17:50:04"
},
{
"a_name": "affles",
"bname": "bua",
"c_number": "10101010",
"dateandtime": "2013-11-30 17:50:04"
},
{
"a_name": "anan",
"bname": "nesh",
"c_number": "2017439441",
"dateandtime": "2013-12-04 17:50:04"
}
]
Client side code using JSONP but still returns null. Using JSONP due to same origin policy
<script>
(function() {
var flickerAPI = "http://apip.com/results.php?jsoncallback=?";
$.getJSON( flickerAPI,
(function( data ) {
$.each( data.items, function( index, value ) {
$('<li>' + value.a_name + '</li>').appendTo('#groups');
});
});
})();
</script>