JSSPs not returning proper character encoding

This article explains how to resolve the issue in Campaign Classic where JSSPs are not returning proper character encoding within the header ContentType if it hasn’t been properly defined.

Description description

Environment

Adobe Campaign Classic

Issue/Symptoms

Sometimes within the header ContentType an error is thrown as it has not been properly defined. When using JSSPs, the content type is not returning application/json; charset=utf-8.

Resolution resolution

To fix this, add ContentType in JavaScript before the rest of the code is executed.

<%
response.setContentType("text/html;charset=utf-8");
%>

or

<%
response.setContentType('application/json;charset=utf-8");
%>

Sample
<%
response.setContentType('application/json');
var x = {'Element1':'Element2'};
document.write(JSON.stringify(x));
%>
recommendation-more-help
3d58f420-19b5-47a0-a122-5c9dab55ec7f