I make the following AJAX pull with JQuery using JSON to an ASP.net Web Service:
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "TestWebService.asmx/Foo",
data: "{}",
dataType: "json",
success: function(msg) {
$("#justpre").html(msg.d);
$("#precode").html(msg.d);
} } );
The TestWebService implements a very simple WebMethod Foo() that returns the following:
[WebMethod]
public string Foo() {
return "multi" + Environment.NewLine + "line" + Environment.NewLine + "comment";
}
Finally, I display the result
<pre id="justpre"></pre>
<pre><code id="precode"></code></pre>
Firefox and Chrome display the returned value as a multi-line comment just fine. IE7, however, renders it as a single-line with no line breaks.
FF, Chrome:
multi
line
comment
IE7:
multi line comment
How can I fix this?