Possible Duplicate:
How do I trim a string in javascript?
I have below string which comes from ajax response
"\r\n\r\n\r\n\r\n\r\n\r\n\r\n\t\r\n\tERROR: Profile : NOT SUCCESS\nCODE : 2\nCATEGORY : TECHNICAL\nSEVERITY : null\nENVIRONMENT : DEV\nAPPLICATION : DEV\nDESCRIPTION : Profile: INVOCATION UNHANDLED EXCEPTION [null]\nDESCRIPTION : Profile: [ServiceAttribute]\nDESCRIPTION : Profile: Instance ID = 20130108124231841\n\r\n\r\n"
I am using below code to trim the string on both ends.
var text = originalRequest.responseText.replace(/^\s+|\s+$/g, '');
However it's removing \n in between message which is coming from ajax response. What i would like to have in the end is
"ERROR: Profile : NOT SUCCESS
CODE : 2
CATEGORY : TECHNICAL
SEVERITY : null
ENVIRONMENT : DEV
APPLICATION : DEV
DESCRIPTION : Profile: INVOCATION UNHANDLED EXCEPTION [null]
DESCRIPTION : Profile: [ServiceAttribute]
DESCRIPTION : Profile: Instance ID = 20130108124231841"
how do i get this? Trying different ways from past 1 hour :(