On my system (running PHP 5.3.15, Apache 2.2.22) xajax works fine. On another system running PHP 5.2.17, Apache 2.2.22), xajax responses are preceded by a blank line. This can be seen in the Firebug Network tab, XHR->Response. There's literally a blank line before
<?xml version="1.0" encoding="utf-8" ?>
What on earth could be causing this and how can I fix it?
Having a blank line before the start of an XML document is an error and leads to the error
Error: XML or text declaration not at start of entity
in the Browser's Error console.
Look through all the PHP includes which are executed before your expected XML output. It is likely that one or more of them has an errant line break either before the opening <?php
or following the closing ?>
, which gets passed to the browser as output before the XML header.
<-- Line break
<?php
?>
<-- Line break
If you are on a UNIX-like system, you can use head
to examine the first line or tail
to examine the last line of each file. Look for the file that doesn't begin or end with <?php / ?>
# In a directory of PHP files...
head -n1 *.php
tail -n1 *.php