I have some AMPScript writing records to a data extension. Using AMPScript I would like to store those records in a variable to access them in a javaScript function.
What is the best way to do it ?
<!DOCTYPE html>
<html>
<head>
</head>
<body>
%%[
VAR @sid, @skey, @jid, @listid, @batchid, @reason, @FieldList, @Rows, @i, @Row, @Name, @Value, @BackIn, @Subscriber, @Status
SET @sid = SubscriberID
SET @skey = _SubscriberKey
SET @jid = JobID
SET @listid = ListID
SET @batchid = _JobSubscriberBatchID
SET @reason = "Landing Page Unsubscribe"
SET @email = emailaddr
SET @FieldList = BuildRowsetFromString(RequestParameter("FieldList"),",")
SET @Rows = Subtract(Rowcount(@FieldList),1)
SET @BackIn="false"
for @i = 1 to @Rows do
Set @Row = Row(@FieldList, @i)
Set @Name = Field(@Row,1)
Set @Value = RequestParameter(@Name)
if @Value=="true" then
Set @Value="true"
Set @BackIn = "true"
else
Set @Value="false"
endif
InsertData('ENT.TEST_PrefChanges1','MemberID',@skey,'ProgramID',@Name,'Subscribed',@Value,'Modified',DateParse(NOW(),1))
next @i
if @BackIn=="true" then
SET @Subscriber = CreateObject("Subscriber")
SetObjectProperty( @Subscriber, "SubscriberKey",@skey)
SetObjectProperty( @Subscriber, "Status", "Active" )
SET @Status = InvokeUpdate(@Subscriber)
%%=v(@Status)=%%
endif
]%%
<script runat="server">
Platform.Load("core", "1");
var records = [];
function(){}
</script>
</body>
</html>