#_AVAILABLESEATS Ajax update | WordPress.org

[ad_1]

Hi Franky,

I noticed that after submitting the registration form, the values for the number of updates and available seats are not updated. We had a problem with this last year because when multiple people start filling out the form at the same time, it depends on who is faster. The slower ones keep signing up for groups that are already full, but they still see vacancies on their form, which is very confusing.
Does the Events Made Easy plugin provide an API? I would need to update the #_AVAILABLESEATS field using ajax.

I can add something like:


// Load data when page loads
updateSeats();

// Update the data every minute (60000 milliseconds)
setInterval(updateSeats, 60000);

// Load the data when the form is submitted
document.getElementById('eme-rsvp-form').addEventListener('submit', function(e) {
e.preventDefault(); // Stop submitting the form until we get the data
updateSeats(function() {
document.getElementById('eme-rsvp-form').submit(); // Submit the form after the data is retrieved
});
});

function updateSeats(callback) {
$.ajax({
url: '/path/to/your/server/api',
method: 'GET',
dataType: 'json',
success: function(data) {
for (var i = 1; i <= 53; i++) {
var seatElement = document.querySelector("#_AVAILABLESEATS{" + i + "}");
if (seatElement) {
seatElement.innerText = data[i.toString()];
}
}
if (callback) {
callback();
}
}
});
}

Unfortunately, I don’t know what to specify as the server API path.

Thank You!

The page I need help with: [log in to see the link]

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer