0

I have a cloudpage that register some customer infos(Fname, Lname, Id...), and theses info needs to be transferred to another CloudPage in order to display the correct Content for that Customer, I'm still a beginner, so I don't really know how to perform that, I tried to use the code below, but it didn't work for me.

my data is json, but before sending it, I parse it and take the id I want and it becomes smthg like this: id=1234

First Page

    Platform.Load("Core", "1.1.1")
    var req = HTTP.Post('https://target-page', 'text/html', id , ['Accept-Encoding'], ['identity']);
    if(req.StatusCode == 200) {
       Write('HTTP request was successful');
    } else {
       Write('HTTP request failed');
    }
</script> 

Target page

<script runat="server">
var data = Request.GetFormField("id");
 data = Platform.Function.ParseJSON(data);
 Write(Stringify(data));
</script
0

By reading your question I could understand the following -

First Page- It is the registration web form where a user can fill in the form.

Target Page - The user should be redirected to target page after clicking on submit button of the form on the first page.

And you want to pass form data to target page so that you can use this data over there.

We can achieve this in number of ways, sharing one of them -

Paste the below HTML code on the first page

<html>
  <body>
    <form action="**place the URL of the target page here**" method="post">
  <label for="fname">First name:</label><br>
  <input type="text" name="fname"><br> // name attribute is the unique identifier through which values will be pulled in the target page.
  <label for="lname">Last name:</label><br>
  <input type="text" name="lname"><br><br>
  <input type="submit" value="Submit">
</form> 
  </body>
</html>

Paste the below SSJS code on the target page

<script runat="server">
  Platform.Load("Core","1");
var firstName = Request.GetFormField("fname");
var lastName = Request.GetFormField("lname");
Write("First Name is" + firstName);
Write("Last Name is" + lastName);
</script>

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.