Is it possible to use Ajax to POST data from within a Server-Side Javascript in the Marketing Cloud? Could the FormData be a problem?
I've been using this code:
var form = new FormData();
form.append("email", "[email protected]");
form.append("first name", "test");
form.append("last name", "test");
form.append("lists", "47");
var url = 'http://existing.working.website.com/';
var contentType = 'application/x-www-form-urlencoded';
var payload = form;
var headerNames = ["cache-control", "postman-token"];
var headerValues = ["no-cache", "a5f59d70-84dc-dce6-8809-03aa098cad3d"];
//var result = HTTP.Post(url, contentType, payload);
var result = HTTP.Post(url, contentType, payload, headerNames, headerValues);
Write("result: "+result.StatusCode + '<br>');
Write(result.Response);
and this one:
var form = new FormData();
form.append("email", "[email protected]");
form.append("first name", "test");
form.append("last name", "test");
form.append("lists", "47");
var settings = {
"async": true,
"crossDomain": true,
"url": "http://existing.working.website.com/",
"method": "POST",
"headers": {
"cache-control": "no-cache",
"postman-token": "a5f59d70-84dc-dce6-8809-03aa098cad3d"
},
"processData": false,
"contentType": false,
"mimeType": "multipart/form-data",
"data": form
}
$.ajax(settings).done(function (response) {
console.log(response);
});