<!DOCTYPE html>
<html lang="en-US">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <title>Ajax Contact Form for Wordpress, Joomla, Drupal - Tailwind</title>
    <meta name="description" content="Tailwind Ajax Form Generator - how to create an Ajax Contact Form with Php Form Builder for Wordpress, Joomla, Drupal or any CMS">
    <link rel="canonical" href="https://www.phpformbuilder.pro/templates/tailwind-forms/ajax-loaded-contact-form-1.html" />

    <!-- Tailwind CSS - for demo purposes only - replace with your Tailwind compilation -->

    <script src="https://cdn.tailwindcss.com"></script>

    <!-- Font awesome icons -->

    <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.15.4/css/solid.css" integrity="sha384-Tv5i09RULyHKMwX0E8wJUqSOaXlyu3SQxORObAI08iUwIalMmN5L6AvlPX2LMoSE" crossorigin="anonymous">
    <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.15.4/css/fontawesome.css" integrity="sha384-jLKHWM3JRmfMU0A5x5AkjWkw/EYfGUAGagvnfryNV3F9VqM98XiIH7VBGVoxVSc7" crossorigin="anonymous">

    <!-- demo styles -->

    <link rel="stylesheet" href="../assets/stylesheets/code-preview-styles.min.css">
</head>

<body>

    <h1 class="text-center">Php Form Builder - Ajax Contact Form for Wordpress, Joomla, Drupal or any CMS<br><small>Tailwind version</small></h1>

    <div class="container mx-auto md:px-5 lg:px-10 xl:px-48">
        <div class="grid-cols-1">
            <p>The Ajax form source code is not available on this page, you'll find it in the <em>templates/ajax-forms</em> folder
            </p>
            <div class="text-center mb-10">
                <a href="https://www.phpformbuilder.pro/documentation/class-doc.php#ajax-loading" class="text-white bg-gray-700 hover:bg-gray-800 focus:ring-4 focus:ring-gray-300 font-medium rounded-lg text-sm px-5 py-2.5 text-center mr-2 mb-2 dark:bg-gray-600 dark:hover:bg-gray-700 dark:focus:ring-gray-900 btn-sm"><strong>Ajax loading</strong> - documentation here <i class="fas fa-arrow-right ml-4"></i></a>
            </div>
            <div id="ajax-form"></div>
        </div>
    </div>

    <!-- Ajax form loader -->

    <script src="../../phpformbuilder/plugins/ajax-data-loader/ajax-data-loader.min.js"></script>

    <script>
        // --- SETUP YOUR FORM(S) BELOW IN THE "ajaxForms" VARIABLE ---
        var ajaxForms = [
            {
                formId: 'ajax-contact-form-1',
                container: '#ajax-form',
                url: 'ajax-forms/contact-form-1.php'
            }
        ];

        // --- NO NEED TO CHANGE ANYTHING AFTER THIS LINE ---
        // --- COPY/PASTE THE FOLLOWING CODE IN THE HTML FILE THAT WILL LOAD THE FORM ---

        document.addEventListener('DOMContentLoaded', function() {
            ajaxForms.forEach(function(currentForm) {
                const $formContainer = document.querySelector(currentForm.container);
                if (typeof($formContainer.dataset.ajaxForm) === 'undefined') {
                    fetch(currentForm.url)
                    .then((response) => {
                        return response.text()
                    })
                    .then((data) => {
                        $formContainer.innerHTML = '';
                        $formContainer.dataset.ajaxForm = currentForm;
                        $formContainer.dataset.ajaxFormId = currentForm.formId;
                        loadData(data, currentForm.container);
                    }).catch((error) => {
                        console.log(error);
                    });
                }
            });
        });
    </script>
</body>

</html>
