I'm using Sprout for registering to events, I want to be able to send a code in the AJAX response when EVENT_AFTER_SAVE occurs. At the moment, I get {success: true}
back, but I want to be able to get {success: true, code: "XXXXX"}
after save
The code will be coming from a Channel called Tokens, which consists of one field: tokenCode. I want to grab one at random and send tokenCode as "code"
This is what I want my AJAX request to be, note var redirect = '' + data.token
$('#token-form').submit(function(event) {
event.preventDefault();
// prepare some variables
var postUrl = 'sprout-forms/entries/save-entry';
var formData = $(this).serialize();
// process the form
$.ajax({
type : 'POST',
url : postUrl,
data : formData,
dataType : 'json',
encode : true
})
.done(function(data) {
if (data.success == true)
{
console.log('success');
console.log(data);
var redirect = '' + data.token
$(location).attr('href', redirect);
}
});
});
Thanks
code
coming from? Is it part of the data model that is saved? – Ben Parizek Apr 30 '19 at 13:37