Skip to content

Instantly share code, notes, and snippets.

@cosenary
Created June 22, 2012 23:36
Show Gist options
  • Save cosenary/2975779 to your computer and use it in GitHub Desktop.
Save cosenary/2975779 to your computer and use it in GitHub Desktop.
Suggestion to improve `load-more button` for TDunham02
// 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);
}
});
<?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
));
@shatmanov
Copy link

load-more button don't work, please fix it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment