Good Please tell me an example of loading a page from the database by id for a fancy box. By clicking on the link
2 answers
<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", } });
|