callback chaining
callback chaining
I'm trying to make the fancybox method to call when the xml ajax is loaded. I've done callbacks on simpler statements, but I can't seem to find the right spot to put it. Any help would be appreciated!
<script type="text/javascript">
$(function () {
$.ajax({
type: "GET",
url: "http://drmartinplasticsurgery.mindbox360.com/images/BeforeAfter/face/PhotoGallery.xml", // replace with absolute URL of your gallery's xml file
dataType: "xml",
success: function(xml) {
$(xml).find('img').each(function(callFancybox) {
var location = 'http://drmartinplasticsurgery.mindbox360.com/images/BeforeAfter/face/'; // replace with absolute path to the directory that holds your images
var url = $(this).attr('src');
var alt = $(this).attr('alt');
$('<li></li>').html('<a href="'+location+''+url+'" rel="gallery" class="grouped_elements" title="'+alt+'"><img src="'+location+''+url+'?action=thumbnail&width=200&height=100" alt="'+alt+'"/></a>').appendTo('#gallery');
});
}
});
});
function callFancybox(){
$("a.grouped_elements").fancybox();
}
</script>