I have two pieces of data to send to a service. I need to send, using javascript, an "action" which is JSON and I need to send a "submittingURL" which is just the encoded URL. Is there a way to send both pieces of data in the POST? If so how? this is all new to me. Below is the same function sending both as a GET and then the second one splits it so the JSON is POSTed.
function sendUnapprovedAction(action) {
var req = new XMLHttpRequest();
var url = '//001l60fbadm:10001/marketingcampaigns/api/v1/campaigns?action=' +
encodeURIComponent(JSON.stringify(action)) + '&submittingURL=' +
encodeURIComponent(_satellite.getVar("Full URL"));
req.open('POST', url, true);
req.setRequestHeader('Content-Type', 'application/json');
req.send();
};
function sendUnapprovedAction(action) {
var req = new XMLHttpRequest();
var url = '//001l60fbadm:10001/marketingcampaigns/api/v1/campaigns?submittingURL=' +
encodeURIComponent(_satellite.getVar("Full URL"));
req.open('POST', url, true);
req.setRequestHeader('Content-Type', 'application/json');
req.send('action=' + encodeURIComponent(JSON.stringify(action)));
};`