• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Catatan How To Fancybox Send Post Data Via Ajax

Kepala Suku

Web & Mobile Developer
Staff member
#1
This thread will give you a working code for sending post data via Ajax using fancybox API.

JavaScript:
            $.fancybox.open({
                src: "ajax-source.php",
                type: "ajax",
                ajax: {
                    settings: {
                        type: "POST",
                        data: {name: "Ahmad Budairi", email: "nusagates@gmail.com"}
                    }
                }
            });
Above code tested and worked using Fancybox version 3.5.7 or the latest version for today.

On previous version, we could use below code to do that:
JavaScript:
    $.fancybox.open({
        href: "ajax-source.php",
        type: "ajax",
        ajax: {
            type: "POST",
            data: {name: "Ahmad Budairi", email: "nusagates@gmail.com"}
        }
    });
The differences between those code are:
  • href changed to src
  • data and type inside settings.