T
Tom Cole
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.reportsCompleted();
}
</script>
<body onload="completed();">
<error>The document type .doc is not supported.</error>
</body>
</html>
Now this does properly call the reportsCompleted method of the parent
frame. The problem I am having is reading the contents of any <error>
tags if they exist:
function reportsCompleted() {
var frame = frames['upload_frame'];
if (frame.document.getElementsByTagName("error").length > 0) { //
there were errors...
var message = "The following error(s) occured:";
for (var i = 0; i <
frame.document.getElementsByTagName("error").length; i++) {
message += "\n" +
frame.document.getElementsByTagName("error").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.reportsCompleted();
}
</script>
<body onload="completed();">
<error>The document type .doc is not supported.</error>
</body>
</html>
Now this does properly call the reportsCompleted method of the parent
frame. The problem I am having is reading the contents of any <error>
tags if they exist:
function reportsCompleted() {
var frame = frames['upload_frame'];
if (frame.document.getElementsByTagName("error").length > 0) { //
there were errors...
var message = "The following error(s) occured:";
for (var i = 0; i <
frame.document.getElementsByTagName("error").length; i++) {
message += "\n" +
frame.document.getElementsByTagName("error").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?