I have 2 landing pages 1 for unsubscribe 1 for thank you page for unsubscribe. I want send subscriber to thank you page if they unsubscribe. But without checking the unsubscribe checkbox it's directly redirecting.
When I click on landing page URL it's directly redirecting with out performing on click. I tried removing on click function still it's redirecting directly also tried checking error code condition still no progress.If comment redirect code it's staying on the current page can someone help me resolve this?
Here is the code i am trying
<input type="submit" value="Submit" onclick="performAction()">
<script>
function performAction(){
if (document.getElementById('MasterUnsubscribeChk').checked){
%%[
SET @subkey = RequestParameter("EmailAddress")
SET @email = RequestParameter("Subscriberkey")
SET @ll_sub = CreateObject("Subscriber")
SetObjectProperty(@ll_sub, "EmailAddress", @email)
SetObjectProperty(@ll_sub, "SubscriberKey", @subkey)
set @subscription = CreateObject("SubscriberList")
//process_listid from your original email
SetObjectProperty( @subscription, "ID", XXXX)
SetObjectProperty( @subscription, "IDSpecified", "true" )
SetObjectProperty( @subscription, "Status", "Unsubscribed" )
SetObjectProperty( @subscription, "StatusSpecified", "true" )
AddObjectArrayItem( @ll_sub, "Lists", @subscription )
SET @ll_statusCode = InvokeUpdate(@ll_sub, @ll_statusMsg, @errorCode)
IF @ll_statusCode != "OK" THEN
RaiseError(@ll_statusMsg, 0, @ll_statusCode, @errorCode)
Else Redirect("https://pub.s4.exacttarget.com/xxxx")
ENDIF
]%%
}
}
</script>