Forum Moderators: open
<?php
if( $_POST["username"] == "samy" )
echo "yes"
else
echo "no"
?>
in my javascript code i am checking the response text for yes or no like the following
if(ajax.responseText=="yes")
alert("Welcome samy");
else
alert("invalid username");
the problem is before the letter y in yes a new line is inserted...
why it is so... is there any method to stop it while sending the response back from the php page... it is fine to do manual removal or split of new line but i want to know why it is a case and what has to be done...?
as the other replies said that there should not be any new line i removed all but still i have a long code where i have formatted for readability so the extra new line is been inserted when the response has been received using ajax...
what i didn was to do a ob_end_clean and then i use to give any echo statement. so if there has to be any new line for the response that will be cleared and the echoed values alone is been fetched by ajax...
if any one like to comment on this then it could be nice...