1

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 Answer 1

11

Have you tried something like this?

success: function(data) {
  $.fancybox({
    'content' : '<h1>' + data.title + '</h1>' + data.body
  });
}
3
  • hey jarrett, ive tried using these code but it kinda disable the fancybox But it proceed to load to the page specificied in HREF from the anchor. any reason why?
    – lilsizzo
    Mar 16, 2011 at 10:18
  • @lilsizzo Have you tried opening a question for this? If you have not, when you do I'd recommend posting the code you are using. Mar 17, 2011 at 3:27
  • @JarrettWidman Unfortunately, it did not worked for me. Could you please have a look at this question? Thanks in advance.
    – Jack
    Jul 11, 2015 at 13:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.