title: Convert \n line breaks to HTML <BR> line breaks
body: <p>I have this simple idea to convert my <code>\n</code> line breaks from my ajax JSON call to <code>&lt;br&gt;</code> so that it would properly display my data. </p>
  
  <p>I tried many different ways to perform the conversion but I keep getting an error saying:</p>
  
  <pre>
  Uncaught TypeError: data.replace is not a function
  </pre>
  
  <p>The issue seems to be the way I'm making this call:</p>
  
  <pre><code>var incident = incident.replace(/\n/g, "&lt;br /&gt;");
  </code></pre>
  
  <p>From what I see on the forums here this is how we're suppose to use <code>.replace</code> but I'm not understading why it doesn't like it.</p>
  
  <p>I tried doing this as well:</p>
  
  <pre><code>"&lt;td colspan='3'&gt;"+incident.Impact.replace(/\n/g, "&lt;br /&gt;")+"&lt;/td&gt;"+
  </code></pre>
  
  <p>This works but if the field is empty it returns with an error stating that it cannot read <code>.replace</code> of undefined. Would anyone have any ideas?</p>
  
  <p>Full code:</p>
  
  <pre><code>$.ajax({
      url: this.basePath() + '/GDI_PROD_Incidents?$filter=ÉtatValue%20ne%20%27Fermé%27&amp;$orderby=PrioritéValue desc',
      dataType: 'json',
      cache: false,
      success: function (data) {
  
          $.each(data.d.results, function (index, incident) {
          var incident = incident.replace(/\n/g, "&lt;br /&gt;");
  
          $('body').append(
  
            "&lt;table border='1' width='800' &gt;"+
            "&lt;tr  bgcolor='#9aff99' align='center'&gt;"+
            "&lt;td width='800px' colspan='4'&gt;&lt;strong&gt;Transfert de connaissances&lt;/strong&gt;&lt;/td&gt;"+
            "&lt;/tr&gt;" +
            "&lt;tr bgcolor='#fff'&gt;"+
            "&lt;td width='165'&gt;Billet:&lt;/td&gt;"+
            "&lt;td&gt;"+incident.Incident+"&lt;/td&gt;"+
            "&lt;td width='165'&gt;Priorité:&lt;/td&gt;"+
            "&lt;td&gt;"+incident.PrioritéValue+"&lt;/td&gt;"+
            "&lt;/tr&gt;"+
            "&lt;tr bgcolor='#fff'&gt;"+
            "&lt;td width='165'&gt;Description:&lt;/td&gt;"+
             "&lt;td colspan='3'&gt;"+incident.Description+"&lt;/td&gt;"+
             "&lt;/tr&gt;"+
             "&lt;tr bgcolor='#fff'&gt;"+
             "&lt;td colspan='4' width='800px' bgcolor='#9aff99' align='center'&gt;Détails&lt;/td&gt;"+
             "&lt;/tr&gt;"+
             "&lt;tr bgcolor='#fff'&gt;"+
             "&lt;td width='165'&gt;Impact:&lt;/td&gt;"+
             "&lt;td colspan='3'&gt;"+incident.Impact+"&lt;/td&gt;"+
             "&lt;/tr&gt;"+
             "&lt;tr bgcolor='#fff'&gt;"+
             "&lt;td width='165'&gt;Dépannage&lt;/td&gt;"+
             "&lt;td colspan='3'&gt;"+incident.Dépanage+"&lt;/td&gt;"+
             "&lt;/tr&gt;"+
             "&lt;tr bgcolor='#fff'&gt;"+
             "&lt;td colspan='4' width='800px' bgcolor='#9aff99' align='center'&gt;Suivi&lt;/td&gt;"+
             "&lt;/tr&gt;"+
             "&lt;tr bgcolor='#fff'&gt;"+
             "&lt;td width='165'&gt;Prochain Suivi:&lt;/td&gt;"+
             "&lt;td colspan='3'&gt;"+incident.Suivi+"&lt;/td&gt;"+
             "&lt;/tr&gt;"+
             "&lt;tr bgcolor='#fff'&gt;"+
             "&lt;td width='165'&gt;Ressource:&lt;/td&gt;"+
             "&lt;td colspan='3'&gt;"+incident.Ressources+"&lt;/td&gt;"+
             "&lt;/tr&gt;"+
             "&lt;tr bgcolor='#fff'&gt;"+
             "&lt;td width='165'&gt;Prime:&lt;/td&gt;"+
             "&lt;td colspan='3'&gt;"+incident.ResponsableValue+"&lt;/td&gt;"+
             "&lt;/tr&gt;"+
             "&lt;/table&gt;"+
             "&lt;br&gt;&lt;br&gt;");
  
          })
  
      }
  });
  </code></pre>