0

I have an AJAX call to Web Method. Web Method returns some statistics. When I build a StringBuilder, I use AppendFormat and AppendLine methods to build it. However, when data is displayed, it is missing new lines.

This is an AJAX call:

$.ajax({
    type: "POST",
    url: "Default.aspx/GeneratePdfs",
    data: JSON.stringify({
           frequency:      $('#ddlReportFrequency option:selected').text(), 
           reportYear:     $('#txtReportYear').val(), 
           reportMonth:    $('#txtReportMonth').val(), 
           reportDay:      $('#txtReportDay').val(),
           reportOption:   $('#ddlReportOption option:selected').text(),
           reportRegion:   $('#txtReportRegion').val(),
           reportSchedule: $('#ddlReportSchedule').val(), 
           reportRegion:   $('#txtReportRegion').val()
   }), 
   contentType: "application/json; charset=utf-8",
   success: function (data) {
       debugger;
       if (data.d != "") {
            $('#rptDisplay').text(data.d);
       }
   }
});

In my Web Method, I'm doing something like this:

sb.AppendFormat("\nData {0} does not have any statements", data);
sb.AppendLine();

return sb.ToString()

What am I doing wrong?

gene
  • 2,098
  • 7
  • 40
  • 98

0 Answers0