B
björn lundin
Hi, I've got a (to me) strange error doing AJAX.
I get the followomg fault in Firebug,
and translated to english it says:
Xml parsing error : junk after document element Address .....
Row 1, column 110
If i alert responseText, it looks fine.
If i run with parameter GET_ONE_RECORD, it works fine,
with responseXML
Any ideas?
XML-tolkningsfel: skräp efter dokumentelement Adress:
http://tova/repowebgui/repoinfo.php?mode=table&action=GET_ONE_RECORD&name=bassign
Radnummer 1, Kolumn 119:
<sourcetext><?xml version='1.0' encoding='ISO-8859-1'?><table
name='bassign' desc='desc of bassign' tablespace='space' clreq='1'/
><column name='abc' type='1' len='4'/><column name='dbc'
type='2' len='9'/><column name='fbc' type='9' len='9'/
><column name='gbc' type='9' len='9'/></table>
----------------------------------------------------------------------------------------------------------------------
^</sourcetext>
</parsererror>
----------------
http://tova/repowebgui/repoinfo.php
<?php
if (isset($_GET['action'])) {
$action=$_GET['action'];
}
if (isset($_GET['mode'])) {
$mode=$_GET['mode'];
}
if (isset($_GET['name'])) {
$name=$_GET['name'];
}
header("Content-type: text/xml");
header("Cache-Control: no-cache, must-revalidate");
//A date in the past
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
echo "<?xml version='1.0' encoding='ISO-8859-1'?>";
switch ($mode) {
case "table":
switch ($action) {
case "GET_ALL_RECORDS":
echo "<tables>";
echo "<table name='bassign' desc='Inv asm'>beskrivning här?</
table>";
echo "<table name='bseq' desc='Inv transport seq'/>";
echo "<table name='xloc' desc='Locations'/>";
echo "<table name='xseq' desc='Transport Sequences'/>";
echo "</tables>";
exit;
break;
case "GET_ONE_RECORD":
echo "<table name='" . $name . "' desc='desc of " . $name .
"' tablespace='space' clreq='1'/>" ;
echo "<column name='abc' type='1' len='4'/>";
echo "<column name='dbc' type='2' len='9'/>";
echo "<column name='fbc' type='9' len='9'/>";
echo "<column name='gbc' type='9' len='9'/>";
echo "</table>";
exit;
break;
default:
echo "<not_implemented mode='$mode' action='$action'/>";
break;
}
break;
default:
echo "<not_implemented mode='$mode' action='$action'/>";
break;
}
?>
-----------------
function loadTableMetadata(tblName) {
var xmlhttp = xhr();
xmlhttp.open("GET","repoinfo.php?
mode=table&action=GET_ONE_RECORD&name="+tblName,false);
xmlhttp.send(null);
var xmlResponse = xmlhttp.responseXML;
alert(xmlResponse);
var tableElement = xmlResponse.getElementsByTagName("table")[0]; //
<--- FAILS
var txtTableName = document.getElementById("txtTableName");
var txtTableDesc = document.getElementById("txtTableDesc");
var txtTableTableSpace =
document.getElementById("txtTableTableSpace");
var chkTableClreq = document.getElementById("chkTableClreq");
txtTableName.value =
tableElement.attributes.getNamedItem("name").value;
txtTableDesc.value =
tableElement.attributes.getNamedItem("desc").value;
txtTableTableSpace.value =
tableElement.attributes.getNamedItem("tablespace").value;
chkTableClreq.value =
tableElement.attributes.getNamedItem("clreq").value;
xmlhttp = null;
xmlResponse = null;
}
I get this on ubuntu 11.04 as well as on mac os Snow Leopard...
I get the followomg fault in Firebug,
and translated to english it says:
Xml parsing error : junk after document element Address .....
Row 1, column 110
If i alert responseText, it looks fine.
If i run with parameter GET_ONE_RECORD, it works fine,
with responseXML
Any ideas?
XML-tolkningsfel: skräp efter dokumentelement Adress:
http://tova/repowebgui/repoinfo.php?mode=table&action=GET_ONE_RECORD&name=bassign
Radnummer 1, Kolumn 119:
<sourcetext><?xml version='1.0' encoding='ISO-8859-1'?><table
name='bassign' desc='desc of bassign' tablespace='space' clreq='1'/
><column name='abc' type='1' len='4'/><column name='dbc'
type='2' len='9'/><column name='fbc' type='9' len='9'/
><column name='gbc' type='9' len='9'/></table>
----------------------------------------------------------------------------------------------------------------------
^</sourcetext>
</parsererror>
----------------
http://tova/repowebgui/repoinfo.php
<?php
if (isset($_GET['action'])) {
$action=$_GET['action'];
}
if (isset($_GET['mode'])) {
$mode=$_GET['mode'];
}
if (isset($_GET['name'])) {
$name=$_GET['name'];
}
header("Content-type: text/xml");
header("Cache-Control: no-cache, must-revalidate");
//A date in the past
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
echo "<?xml version='1.0' encoding='ISO-8859-1'?>";
switch ($mode) {
case "table":
switch ($action) {
case "GET_ALL_RECORDS":
echo "<tables>";
echo "<table name='bassign' desc='Inv asm'>beskrivning här?</
table>";
echo "<table name='bseq' desc='Inv transport seq'/>";
echo "<table name='xloc' desc='Locations'/>";
echo "<table name='xseq' desc='Transport Sequences'/>";
echo "</tables>";
exit;
break;
case "GET_ONE_RECORD":
echo "<table name='" . $name . "' desc='desc of " . $name .
"' tablespace='space' clreq='1'/>" ;
echo "<column name='abc' type='1' len='4'/>";
echo "<column name='dbc' type='2' len='9'/>";
echo "<column name='fbc' type='9' len='9'/>";
echo "<column name='gbc' type='9' len='9'/>";
echo "</table>";
exit;
break;
default:
echo "<not_implemented mode='$mode' action='$action'/>";
break;
}
break;
default:
echo "<not_implemented mode='$mode' action='$action'/>";
break;
}
?>
-----------------
function loadTableMetadata(tblName) {
var xmlhttp = xhr();
xmlhttp.open("GET","repoinfo.php?
mode=table&action=GET_ONE_RECORD&name="+tblName,false);
xmlhttp.send(null);
var xmlResponse = xmlhttp.responseXML;
alert(xmlResponse);
var tableElement = xmlResponse.getElementsByTagName("table")[0]; //
<--- FAILS
var txtTableName = document.getElementById("txtTableName");
var txtTableDesc = document.getElementById("txtTableDesc");
var txtTableTableSpace =
document.getElementById("txtTableTableSpace");
var chkTableClreq = document.getElementById("chkTableClreq");
txtTableName.value =
tableElement.attributes.getNamedItem("name").value;
txtTableDesc.value =
tableElement.attributes.getNamedItem("desc").value;
txtTableTableSpace.value =
tableElement.attributes.getNamedItem("tablespace").value;
chkTableClreq.value =
tableElement.attributes.getNamedItem("clreq").value;
xmlhttp = null;
xmlResponse = null;
}
I get this on ubuntu 11.04 as well as on mac os Snow Leopard...