Page 1 of 1

responseText from php coming with a new line character

Posted: Mon May 05, 2008 6:30 am
by nsalam
Hi ,
I am developing a small web application using php and and mysql.
While making an ajax call , I am getting some extra characters like '\n\r' at the beginning of the responseText.

The php code snippet is shown here :
$response = '';
$response = $response.'yes';
print $response;
************
I alert the responseText using javascript like this :
alert('>>'+httpRequest.responseText+'<<');

The output comes like this :
>>
yes<<
but I expect the output as >>yes<<
I am still clueless as to from where this character is coming in the beginning of the reponse.

debugging with firebug shows some characters like '/n/r' in the responseText.

Can anybody give me some pointers ?
Somebody has also found the same problem before.
http://www.webmasterworld.com/javascript/3462694.htm

nab

Re: responseText from php coming with a new line character

Posted: Mon May 05, 2008 7:04 am
by hpuiu
Hi,

Please make sure you don't have any new lines before the <?php tag.
Thos are sent to the browser too.

PuYa

Re: responseText from php coming with a new line character

Posted: Mon May 05, 2008 11:05 am
by nsalam
I have ensured that there are no new lines before <?php
Still after that while debugging using firebug, the responseText is having the character '\r\n' in the front.