问题
I have an anchor tag with a click event on it
$('a').click(function(){
$.ajax({
url: 'ajax/test.php',
data: {id: 123, count: 456},
success: function(data) {
//lightbox data
}
});
});
The response will look something like
{
title: 'My Title',
body: 'My Body'
}
I want to show this in a fancybox.
Where I am stuck is creating and showing a fancybox around this content on the fly?
回答1:
Have you tried something like this?
success: function(data) {
$.fancybox({
'content' : '<h1>' + data.title + '</h1>' + data.body
});
}
来源:https://stackoverflow.com/questions/4445992/fancybox-show-ajax-content