fancybox - show ajax content?

狂风中的少年 提交于 2019-12-12 09:13:19

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!