Created
June 22, 2012 23:36
-
-
Save cosenary/2975779 to your computer and use it in GitHub Desktop.
Suggestion to improve `load-more button` for TDunham02
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Relace the jQuery AJAX snippet by this: | |
$.ajax({ | |
type: 'GET', | |
url: 'ajax.php', | |
data: { | |
tag: tag, | |
max_id: maxid | |
}, | |
dataType: 'json', | |
cache: false, | |
success: function(data) { | |
// Output data | |
$.each(data.images, function(i, img) { | |
$('ul#photos').append('<li><a href="/media.php?id=' + img.id + '&user=' + img.user + '"<img src="' + img.url + '"></a></li>'); | |
}); | |
// Store new maxid | |
$('#more').data('maxid', data.next_id); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Replace the data compilation and output (ajax.php file) by this: | |
$images = array(); | |
foreach ($media->data as $data) { | |
$images[] = array( | |
'id' => $data->id, | |
'url' => $data->images->thumbnail->url, | |
'user' => $data->user->username | |
); | |
} | |
echo json_encode(array( | |
'next_id' => $media->pagination->next_max_id, | |
'images' => $images | |
)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
load-more button don't work, please fix it!