I'm building a preference center page and am trying to make use of LogUnsubEvent.
Microsite Structure is:
- Unsubscribe Page
- Actions Page (contains LogUnsubEvent script)
When I use a form on Unsubscribe Page with an action to POST to Actions Page, everything works perfectly. However, I'd rather have the lead stay on the Unsubscribe Page. Using a jQuery AJAX call to the Actions Page results in...nothing. No opt out processed, no response.
What needs to be done to use an AJAX post instead of a form submission?
AJAX Call:
$("#optOutFormSubmit").click(function(e) {
e.preventDefault();
if ($("#optOut").is(":checked")) {
$.ajax({
method: "POST",
url: "http://cloud.email.customdecorators.com/Preferences/Actions",
data: {
email_address: "example@example.com",
jobid: "123",
listid: "123",
batchid: "",
}
})
.done(function(msg) {
console.log("ajax posted");
console.log(msg);
});
$("#optOutForm").hide();
$(".sucessMessage").removeClass("hidden");
} else {
$(".helpText").removeClass("hidden");
}
});