Stec Records Forum

Tools to make music

News: We are back.  We've updated the look of the forum with a new "theme" that works better on mobile devices. Also note that we check all new user requests for spam violations. If you believe you have been rejected unfairly please contact us and we will attempt to resolve it with you.  - Stecrew

Extra lines in response to an AJAX request (Read 2420 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 »