AJAX: I am using these line of JavaScript to alter the content in a div called "xtras" (a server side PHP script actually generates the XML content)
var html = xmlObj.getElementsByTagNam
e('result'
).item(0).
firstChild
.data;
document.getElementById('x
tras').inn
erHTML = html;
I seem to be getting the XML back from the PHP script fine - Firebug displays the response correctly.
CASE 1 (successful):
If I set the PHP script to return this:
$strMsg = 'BOO!';
header('Content-Type: text/xml');
header('Pragma: no-cache');
echo '<?xml version="1.0" encoding="UTF-8"?>';
echo '<result>';
echo $strMsg;
echo '</result>';
Firebug shows that the response received was this:
<?xml version="1.0" encoding="UTF-8"?><result>
BOO!</resu
lt>
and the div "xtras" has its content updated successfully. "BOO!"
CASE 2 (failure):
If I set the PHP script to return this:
$strMsg = '<h3>More images of the SLC-T2</h3>
<div class="xtra-img"><img src="../images/products/SL
C-T2_img1.
jpg" /></div>
<div class="xtra-img"><img src="../images/products/SL
C-T2_img3.
jpg" />
<div class="caption">Available with up to 4 tiers of LEDs</div>
</div>';
header('Content-Type: text/xml');
header('Pragma: no-cache');
echo '<?xml version="1.0" encoding="UTF-8"?>';
echo '<result>';
echo $strMsg;
echo '</result>';
Firebug shows that the response received was this:
<?xml version="1.0" encoding="UTF-8"?><result>
<h3>More images of the SLC-T2</h3>
<div class="xtra-img"><img src="../images/products/SL
C-T2_img1.
jpg" /></div>
<div class="xtra-img"><img src="../images/products/SL
C-T2_img3.
jpg" />
<div class="caption">Available with up to 4 tiers of LEDs</div>
</div></result>
But the content of the div "xtras" is empty! No error messages generated. Even if the image paths were wrong (thery're not), I should get the caption text at least.
Any assistance welcomed. Yerfdoggy
Start Free Trial