How to sanitize data sent from the server in ajax call ?

How to sanitize data sent from the server in ajax call ?

I have the following quiz component here.

There are 10 questions and on click of the result of the final question , your performance of the over all quiz is shown, the response is fetched though a ajax request (in scripts.js) , like so:


  1.  $.ajax({
  2.                 type: "POST",
  3.                 url: $("#quizForm input#QuizResultPreview").val(),
  4.                 dataType: 'html',
  5.                 contentType: 'application/json',
  6.                 data:JSON.stringify(quizAttempt),
  7.                 success: function(data) {
  8.                     /* console.log(data);
  9.                     var data = JSON.parse(data);
  10.                     var html = '';
  11.                     for( var i = 0; i < data.length  ; i++ ) {
  12.                         if( data[i].CorrectSelectionResponse !== null ) {
  13.                             html += "<div class='quiz__indi__answerwrapper'><span>"+ data[i].QID.slice(1 , data[i].QID.length )  +"</span><span>"+ strip(data[i].Question) +"</span><span>"+ data[i].CorrectSelectionResponse +"</span></div>";
  14.                         } else {
  15.                             html += "<div class='quiz__indi__answerwrapper'><span>"+ data[i].QID.slice(1 , data[i].QID.length )  +"</span><span>"+ strip(data[i].Question) +"</span><span>"+ data[i].WrongSelectionResponse +"</span></div>";    
  16.                         }
  17.                     }  */
  18.                     $('#resultTemp').html(data);

  19.                 },
  20.                 error: function(xhr) {
  21.                     $("#resultTemp").text(xhr);
  22.                     $('#resultTemp').show();
  23.                 },
  24.                 failure: function(xhr) {

  25.                     $("#resultTemp").text(xhr);
  26.                     $('#resultTemp').show();
  27.                 }
  28.             });
In the html though i see a few weird characters displayed like so (The same can be seen by navigating the quiz component link i shared above). how do i sanitize the data sent from the server ?