I made this js code to get the data of the inputs (THIS PLEASURE OK THAT PART) from the page and send it to VTEX (NOT SENDING). It must be some detail that I've forgotten. I've done several js to capture the data, register in VTEX and then trigger an event (SEND EMAIL TO USER) and I never had a problem. However, this js does not need to have any events, that is, it will not send email to the user, I just want to collect the data.
(function($){
if(typeof newsButtonClick == "function"){
newsButtonClick = function(instanceId) {
var clientName = $('#' + instanceId + ' .newsletter-client-name').val();
var clientEmail = $('#' + instanceId + ' .newsletter-client-email').val();
var internalPage = $('#' + instanceId + '#newsInternalPage').val();
var internalPart = $('#' + instanceId + '#newsInternalPart').val();
var internalCampaign = $('#' + instanceId + '#newsInternalCampaign').val();
if (clientName.length > 0 && newsCheckEmail(clientEmail)) {
var dataToPost = { newsletterClientName: (clientName == originalNewsNameFieldValue ? "" : clientName), newsletterClientEmail: clientEmail, newsInternalPage: internalPage, newsInternalPart: internalPart, newsInternalCampaign: internalCampaign };
var url = '/no-cache/Newsletter.aspx';
newsletterAjaxRequest('POST', url, dataToPost, '#' + instanceId + '.newsletter', '');
var now = new Date();
var y = now.getFullYear(),
m = now.getMonth(),
d = now.getDate(),
fullDate = y+"-"+(m+1)+"-"+d
try {
lista : {
nm_lista : "teste";
nm_email : clientEmail;
nome : clientName;
atualizar : "1";
dt_cadastro : {
valor : fullDate;
atualizar : "1";
}
}
console.log("ok");
} catch (e) {
console.log(e);
}
}
}
}
}(jQuery));