I have a rather complicated business application that uses Ajax. Part
of this form requires uploading documents, which I cannot do using
Ajax, so I post the form to an IFrame. This part works just fine.
The problem I have is that my server process returns some content to
the IFrame to complete form processing and to report any errors that
might have occured. Here's an example of what may be written back:
<html>
<head>
<script type="text/javascript">
function completed() {
window.parent.r eportsCompleted ();
}
</script>
<body onload="complet ed();">
<error>The document type .doc is not supported.</error>
</body>
</html>
Now this does properly call the reportsComplete d method of the parent
frame. The problem I am having is reading the contents of any <error>
tags if they exist:
function reportsComplete d() {
var frame = frames['upload_frame'];
if (frame.document .getElementsByT agName("error") .length 0) { //
there were errors...
var message = "The following error(s) occured:";
for (var i = 0; i <
frame.document. getElementsByTa gName("error"). length; i++) {
message += "\n" +
frame.document. getElementsByTa gName("error")[i].nodeValue();
}
alert(message);
}
}
The problem is that I never get the contents of the error tags
displayed. I only see an alert window that says "The following
error(s) occured:".
What am I doing wrong?
of this form requires uploading documents, which I cannot do using
Ajax, so I post the form to an IFrame. This part works just fine.
The problem I have is that my server process returns some content to
the IFrame to complete form processing and to report any errors that
might have occured. Here's an example of what may be written back:
<html>
<head>
<script type="text/javascript">
function completed() {
window.parent.r eportsCompleted ();
}
</script>
<body onload="complet ed();">
<error>The document type .doc is not supported.</error>
</body>
</html>
Now this does properly call the reportsComplete d method of the parent
frame. The problem I am having is reading the contents of any <error>
tags if they exist:
function reportsComplete d() {
var frame = frames['upload_frame'];
if (frame.document .getElementsByT agName("error") .length 0) { //
there were errors...
var message = "The following error(s) occured:";
for (var i = 0; i <
frame.document. getElementsByTa gName("error"). length; i++) {
message += "\n" +
frame.document. getElementsByTa gName("error")[i].nodeValue();
}
alert(message);
}
}
The problem is that I never get the contents of the error tags
displayed. I only see an alert window that says "The following
error(s) occured:".
What am I doing wrong?
Comment