loading content into fancybox modal using ajax

This loads content into a fancybox modal using an ajax request so you can specify a url to load into the modal when the button is clicked

HTML

<p><button id='open_popup' class='btn btn-primary' onclick="$.fancybox({ href: '/view/quotes/fKbDL/time-you-enjoyed-wasting-is-not-wasted-time/', type: 'ajax'});">Open Popup (Modal False)</button></p>

Scripts

<link rel="stylesheet" type="text/css" media="all" href="https://cdnjs.cloudflare.com/ajax/libs/fancybox/3.3.5/jquery.fancybox.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/fancybox/3.3.5/jquery.fancybox.js"></script>

Javascript

// Example
/*
    $.fancybox({
        width: 400,
        height: 400,
        autoSize: false,
        href: '/some/url-to-load',
        type: 'ajax'
    });
*/
// i will include an inline example above

// example 2, this one works for  newer versions of fancybox
$("#button").click(function() {
    $.fancybox.open({
        href: "ajax.php",
        type: "ajax",
        ajax: {
            type: "POST",
            data: {
                temp: "stuff"
            }
        }
    });
});

Other Items in javascript
Page Views

This page has been viewed 178 times.

Search Code
Search Code by entering your search text above.
Welcome

This is my test area for webdev. I keep a collection of code snippits here, mostly for my reference. Also if i find a good site, i usually add it here.

❤👩‍💻🕹

Random Quote
Don't look to be the next Facebook, try to solve a real problem instead.
Unknown