I have a little script to request json data from my database. Here is the Code
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>
<script type="text/javascript">
$(function() {
$(document).ready(function() {
var keyword = "1";
var baseurl1 = "json_data2.php?l=" + keyword;
// Product Count
var json = (function() {
var json = null;
$.ajax({
'async': false,
'global': false,
'url': baseurl1,
'dataType': "json",
'success': function(data) {
json = data;
}
});
return json;
})();
console.log(json);
});
});
</script>
When my Feed looks like this
{"limit": [{"rows":"127"}]}
I get "Object {limit: Array[1]}" in the console. So it seems to word. I can also alert json.limit[0].rows and get 127 shown. So far so good.
When I try to get another feed of data which looks like this
{"posts": [{"productname":"Das kleine Ich bin ich","link":"if3OHlvncaIY7A7VGze7VSIeAAZAIZV83cvaG%2B5w3U48cuooMp9qZZJkdQzwyGEXgk8LCR9kD7nY6Y%2FSR0RnjRJo44jHguoaesLAa4mLhuKpuLsfty85ZaePH%2FHReJTc","imgurl":"img\/products\/mytoys\/das-kleine-ich-bin-ich.jpg","price":"13.90","oldprice":"","sale":""},]}
the console log shows up with "null". What could be the issue? I mean I change nothing on the code, just the Url. The datafeed is JSON and I also visited the datafeed in my browser, it's showing up correctly. Any pointers?