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


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


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


// Example
        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() {
        href: "ajax.php",
        type: "ajax",
        ajax: {
            type: "POST",
            data: {
                temp: "stuff"

Other Items in javascript
Search Code
Search Code by entering your search text above.

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
Be Yourself, Back Yourself
Kristie Bennett, Survivor