Stec Records Forum

Tools to make music

News: Note that we've improved the security of the forum by enhancing the sign up form.

Extra lines in response to an AJAX request (Read 2461 times)

  • Administrator
  • Hero Member
  • Chief Administrator
  • Posts: 771
  • Karma: +0/-0
  • Time reveals truth.
    • Bob Sellon's Home Page
I started noticing extra line feeds showing up at the beginning of some html text that was being written to a textarea field in an AJAX callback.

document.getElementById("myTextAreaField").value = content;

The "content" is anything that the requested php file echoed or printed. In my case, the filed included many files, none of which printed or echoed anything outside of a function. Very strange.

I eventually traced the problem to extra line feeds at the bottom of my php files after the ?>

If there was more than one line feed after the ?>, it was added to the response that showed up in the "content" of the callback.  I guess it makes sense; once you are outside of the ?> you are back in raw html.

« Last Edit: May 13, 2011, 12:43:26 PM by bsellon »