/** * AutoPoster Frontend AJAX Handler * This provides fallback AJAX functionality */ jQuery(document).ready(function($) { 'use strict'; // Check if we're on a page with the autoposter form if ($('#autoposter-frontend-form').length) { // Fallback AJAX handler if inline script fails $(document).on('submit', '#autoposter-frontend-form', function(e) { // If the form already has inline JS handling, let it handle if (window.autoposterFormHandled) { return; } e.preventDefault(); console.log('Fallback AJAX handler triggered'); var $form = $(this); var $submitBtn = $form.find('.submit-button'); var $spinner = $form.find('.spinner-container'); var $result = $('#frontend-result'); // Show loading $submitBtn.prop('disabled', true).text('Processing...'); $spinner.show(); $result.hide().removeClass('success error').html(''); // Submit via AJAX $.ajax({ url: autoposter_ajax.ajax_url, type: 'POST', data: new FormData(this), processData: false, contentType: false, dataType: 'json', success: function(response) { if (response.success) { $result.html( '
Your event has been created and is ready for review.
' + '' + '' + (response.data.message || 'An error occurred') + '
' + 'Unable to connect to server. Please try again.
' + '