0

Our client is looking for a preference center where there is no page refreshing, the user click on submit and a message pops up

I did not do this before, so I made an example to achive this, with a simple example, I need a scriot javascript & json code source

JS file :

<script>
function loadXMLDoc() {
  
  // retrieve data
  const firstName = document.getElementById("first_name").value;
  const lastName = document.getElementById("last_name").value;
  const email = document.getElementById("email").value;
  
  
  var xhttp = new XMLHttpRequest();
  
  xhttp.onreadystatechange = function() {
    if (this.readyState == 4 && this.status == 200) {
      const elm = JSON.parse(this.responseText);
      console.log(elm);
      document.getElementById("demo").innerHTML = elm.Message;
    }
  };
  xhttp.open("POST", "https://myurl", true);
  
  //Send the proper header information along with the request
  xhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
  
  xhttp.send("email="+email+"&firstname="+firstName+"&lastname="+lastName);
}
</script>

AMPscript :

%%[

    VAR @Message
    SET @EmailAddress = RequestParameter('email')
    SET @FirstName = RequestParameter('firstname')
    SET @LastName = RequestParameter('email')
    
    IF NOT EMPTY(@EmailAddress) THEN
        SET @Message = CONCAT("Hello",@FirstName, " ", @LastName, ",", "Your email is not empty, Thanks!")
    ELSE
        SET @Message = "Email not provided"
    ENDIF
]%%
{
    "Message" : "%%=v(@Message)=%%"
}

Very basic code, but after checking the code, I got this in the network ( developer console of chrome ) :

enter image description here

But after having a discussion with the team, this is fine, but need improvement, we can't make PII visible like this

Any suggestions, on to do so ?

I saw that activation of HTTPS protocol can make this possible ? but how ?

0

Encryption occurs between the browser and the server with HTTPS. Only the browser and the server are able to see this information. Try using something like WireShark to see what the data looks like when being sent over the Internet. The browser knows what the data is in the form, because it was the one to encrypt and send this data in the first place.

2
  • So, if I am using my urls starts with https then my data is encrypted already, isn't it ? and what we see in the network console is completly normal ? what do you think ?
    – TaouBen
    Sep 23 at 14:43
  • @TaouBen yes, precisely. The browser won't show the data encrypted, but as long as you use https, it will definitely be encrypted over the network.
    – sfdcfox
    Sep 23 at 14:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.