cancel
Showing results for 
Search instead for 
Did you mean: 

Alfresco.util.Ajax.request, text content and line breaks

vincent-kali
Star Contributor
Star Contributor

Hi,

I want to read text file content line by line from a YUI widget using an Ajax request.

Everything works fine except that line breaks are removed from server response. Code is added below.

Any advice to preserve line breaks in the text response ?

<code>

Alfresco.util.Ajax.request({
        url: Alfresco.constants.PROXY_URI + "slingshot/node/content/workspace/SpacesStore/xxxxxxxxxxxxxxxxx",
        successCallback: {
         fn: function _getFileContent_success(p_response) {
          var fileItems = (p_response.serverResponse.responseText).split("\r\n");

              .... process lines .......
         },
         scope: this
        },
        failureCallback: {
         fn: function _getFileContent_failure(p_response) {
          console.log("Error, unable to get file content: " + p_response);
         },
         scope: this
        }
       });

</code>

Thanks.

1 REPLY 1

mikel_asla
Star Contributor
Star Contributor

Hi

When you say 

.... process lines .......

Do you process more that one?

If yes then you got line breaks but you're spliting text on them with .split("\r\n")

After that code you are converting the response to an array of lines without line breaks 

Regards,

Mikel