responseText from php coming with a new line character

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
nsalam
Forum Newbie
Posts: 6
Joined: Mon May 05, 2008 6:15 am

responseText from php coming with a new line character

Post 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
hpuiu
Forum Newbie
Posts: 2
Joined: Mon May 05, 2008 6:50 am

Re: responseText from php coming with a new line character

Post 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
nsalam
Forum Newbie
Posts: 6
Joined: Mon May 05, 2008 6:15 am

Re: responseText from php coming with a new line character

Post 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.
Post Reply