Action Required: To play videos, please enable JavaScript or use a modern browser (Chrome, Edge, or Firefox).
Skip to content
window.addEventListener("load", () => {
setTimeout(() => {
const e = jQuery,
t = "#save_groups_plus_team_member",
o = e(t);
if (o.length) {
// Remove the ORIGINAL delegated handler from document
e(document).off("submit", t);
// Now bind our improved handler
o.on("submit", function (s) {
s.preventDefault();
e.ajax({
type: "POST",
url: learndashGroupsPlusFrontend.ajaxurl,
data: {
action: "action_save_groups_plus_team_member",
data: e(this).serialize() + "&nonce=" + e(this).data("nonce"),
},
dataType: "JSON",
beforeSend: () => {
o.find(".form_message").empty();
e(t + "_btn > i").addClass("fa-spinner fa-spin");
o.find("button[type='submit']").attr("disabled", !0);
},
success: (s) => {
if (s && s.success) return location.reload();
const n =
s && s.errors
? s.errors
: "An unexpected error occurred.";
o.find(".form_message").html(formatErrors(n));
},
error: () =>
o.find(".form_message").html(
formatErrors("A server error occurred. Please try again.")
),
complete: () => {
e(t + "_btn > i").attr("class", "fa fa-angle-right");
o.find("button[type='submit']").prop("disabled", !1);
},
});
});
}
function formatErrors(msg) {
if (typeof msg === "string") return '' + msg + "
";
if (typeof msg === "object") {
let html = "";
for (const key in msg) {
html += '' + msg[key] + "
";
}
return html;
}
return 'An unexpected error occurred.
';
}
}, 500);
});