Good Please tell me an example of loading a page from the database by id for a fancy box. By clicking on the link

  • I mean in the database of info about the page by id. Is there an example? I can't find what I need - IOleg
  • @IOleg, If you are given a comprehensive answer, mark it as correct (click on the check mark next to the selected answer). - Nicolas Chabanovsky

2 answers 2

<a class="various fancybox.ajax" data-fancybox-type="ajax" href="/demo/ajax.php">Ajax</a> $(".fancybox").fancybox(); 

This is all that is required from fancybox. And in the ajax.php file the info about the page is loaded by id. Do the download, it is no longer a workbox.

    The easiest option is not to put each link additional attribute data-fancybox-type = "ajax" you can perform this construction

      <a class="need" data-id="2" href="/demo/ajax.php">Дайте 2</a> ... $('a.need').fancybox({ type: 'ajax', ajax : { type : "POST", data : 'id=' + $(this).attr('data-id') } }); 

    A POST request with the id specified in the data-id will be sent to /demo/ajax.php

    Or even easier

     <a class="need" href="/demo/ajax.php?id=3">Дайте 3</a> ... $('a.need').fancybox({ type: 'ajax', ajax : { type : "POST", } });