Reputation: 3325
$.ajax seems to be broken for me:
$.ajax({url:'getGalleries.php', datatype:'jsonp',
success: function(data){
$('#galleries').html('');
$.each(data,function(key,value) {
$('#galleries').append(value);
});
},
complete: function() { loading.hide(); }
});
The php is just passing:
<?php echo json_encode(array("associative"=>"arrays","are"=>"cool")); ?>
It seems to be fine with another function that uses just regular arrays, but for some reason my jQuery is spitting out a data that is an array of every character in the JSON string when I pass it a json encoded associative array.
The PHP page is grabbing a json list of image galleries then finding the first image in each gallery. I'm making an associative array with the gallery name as the index to then pass back to my html page to show each of my galleries and a sample image.
Upvotes: 1
Views: 2885
Reputation: 224913
You have two problems. One is that datatype
's capitalization is incorrect; it should be dataType
. Second, it isn't JSONP as far as I can see - it's JSON. So use 'json'
as the dataType
.
Upvotes: 3
Reputation: 12059
I am guessing that you need to capitalize dataType
:
$.ajax({url:'getGalleries.php', dataType:'jsonp',
success: function(data){
$('#galleries').html('');
$.each(data,function(key,value) {
$('#galleries').append(value);
});
},
complete: function() { loading.hide(); }
});
Upvotes: 0