472,983 Members | 2,608 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,983 software developers and data experts.

Problem posting form to an IFrame

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").leng th 0) { //
there were errors...
var message = "The following error(s) occured:";
for (var i = 0; i <
frame.document.getElementsByTagName("error").lengt h; i++) {
message += "\n" +
frame.document.getElementsByTagName("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?
Jun 27 '08 #1
14 1740
On Apr 16, 3:30*pm, Tom Cole <tco...@gmail.comwrote:
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").leng th 0) { //
there were errors...
* * * * var message = "The following error(s) occured:";
* * * * for (var i = 0; i <
frame.document.getElementsByTagName("error").lengt h; i++) {
* * * * * * message += "\n" +
frame.document.getElementsByTagName("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?
why not use .innerHTML instead of your non existent .nodeValue()?
http://developer.mozilla.org/en/docs...ment.nodeValue
Jun 27 '08 #2
Tom Cole wrote:
[...]
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>

[...] 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").leng th 0) { //
there were errors...
Use instead:

if (frame)
{
// add feature test here
var c = frame.document.getElementsByTagName("error");

var len = c.length;

if (len 0)
{
var message = "The following error(s) occured:";
for (var i = 0; i <
.length; i++) {
var message = [];

for (var i = 0; i < len; i++)
{
message += "\n" +
frame.document.getElementsByTagName("error")[i].nodeValue();
message.push(c[i].nodeValue;
}
alert(message);
}

window.alert(message.join("\n"));
}
}
}
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?
Using non-HTML elements in a supposed-to-be HTML document,
and calling a property although it is not a method.

http://jibbering.com/faq/#FAQ4_43
http://validator.w3.org/
PointedEars
--
Anyone who slaps a 'this page is best viewed with Browser X' label on
a Web page appears to be yearning for the bad old days, before the Web,
when you had very little chance of reading a document written on another
computer, another word processor, or another network. -- Tim Berners-Lee
Jun 27 '08 #3
the <erroris not standard HTML elements then different browsers have
diffent behavior on unknow tag

for IE, you should define a namespace for custom elements
(xmlns:my="http://xxxx....", then use my:error, then use
document.getELementsByTagName("error"))
for Firefox, you need not to define namespace, but you have to write
document.getElementsByTagName("my:error");
It'd better to use standard HTML element (p, span) and innerHTML.

On Apr 17, 2:30*am, Tom Cole <tco...@gmail.comwrote:
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").leng th 0) { //
there were errors...
* * * * var message = "The following error(s) occured:";
* * * * for (var i = 0; i <
frame.document.getElementsByTagName("error").lengt h; i++) {
* * * * * * message += "\n" +
frame.document.getElementsByTagName("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?
Jun 27 '08 #4
On Apr 17, 8:20 am, gunnrosebutpeace wrote:
the <erroris not standard HTML elements then different
browsers have diffent behavior on unknow tag

for IE, you should define a namespace for custom elements
(xmlns:my="http://xxxx....", then use my:error, then use
document.getELementsByTagName("error"))
for Firefox, you need not to define namespace, but you have
to write document.getElementsByTagName("my:error");
It'd better to use standard HTML element (p, span) and
innerHTML.
Because different browsers have (and should be expected to have)
different behaviour when they encounter an unrecognised element in an
HTML document the specifics of the behaviour of just two of those
browsers is of very little use or relevance.

Because the response that includes the message is being generated it
would be possible to generate it in any form, and the simplest form
would be to take the character sequence that would otherwise appear in
the "error" element and appropriately escape it for inclusion in a
javascript string literal context and insert it as a string literal
argument to the - reportsCompleted - function call:-

// with double quotes and line terminators in the string (at minimum)
// replaces with their equivalent escape sequences.
window.parent.reportsCompleted(
"The document type .doc is not supported"
);

(with either no argument or an empty string as an argument in the
event that there was no error to report.)

Or assign it to a local variable (perhaps called 'error' for example,
but preferably something longer and less likely to coincide with a pre-
existing window property):-

// with double quotes and line terminators in the string (at minimum)
// replaces with their equivalent escape sequences.
var error = "The document type .doc is not supported."

- and have the reportsCompleted - function access it as:-

frames['upload_frame'].error

And in the (apparently likely( event that it is anticipated that there
be more than one error to report the string literals of the errors
could instead appear in an array literal.
Jun 27 '08 #5
Thomas 'PointedEars' Lahn wrote:
Tom Cole wrote:
[...]
> message += "\n" +
frame.document.getElementsByTagName("error")[i].nodeValue();

message.push(c[i].nodeValue;
message.push(c[i].nodeValue);

and it should work with Valid markup. Sorry.
PointedEars
--
Prototype.js was written by people who don't know javascript for people
who don't know javascript. People who don't know javascript are not
the best source of advice on designing systems that use javascript.
-- Richard Cornford, cljs, <f8*******************@news.demon.co.uk>
Jun 27 '08 #6
On Apr 17, 6:29*am, Thomas 'PointedEars' Lahn <PointedE...@web.de>
wrote:
Thomas 'PointedEars' Lahn wrote:
Tom Cole wrote:
[...]
* * * * * * message += "\n" +
frame.document.getElementsByTagName("error")[i].nodeValue();
* * * * message.push(c[i].nodeValue;

* * * * message.push(c[i].nodeValue);

and it should work with Valid markup. *Sorry.

PointedEars
--
Prototype.js was written by people who don't know javascript for people
who don't know javascript. People who don't know javascript are not
the best source of advice on designing systems that use javascript.
* -- Richard Cornford, cljs, <f806at$ail$1$8300d...@news.demon.co.uk>
Thank you for you assistance. I should have figured using an unknown
tag would cause unpredictable results. I've changed all the tags to
<spanelements and use the className to denote them as errors or not.
This seems to work just fine.

Jun 27 '08 #7
On 16 Apr, 20:30, Tom Cole <tco...@gmail.comwrote:
I have a rather complicated business application that uses Ajax. Part
of this form requires uploading documents, which I cannot do using
Ajax,
Why not?
Jun 27 '08 #8
On Apr 17, 10:56*am, Captain Paralytic <paul_laut...@yahoo.comwrote:
On 16 Apr, 20:30, Tom Cole <tco...@gmail.comwrote:I have a rather complicated business application that uses Ajax. Part
of this form requires uploading documents, which I cannot do using
Ajax,

Why not?
How would you perform a fileupload with Ajax?
Jun 27 '08 #9
Tom Cole wrote:
On Apr 17, 10:56 am, Captain Paralytic <paul_laut...@yahoo.comwrote:
>On 16 Apr, 20:30, Tom Cole <tco...@gmail.comwrote:I have a rather complicated business application that uses Ajax. Part
>>of this form requires uploading documents, which I cannot do using
Ajax,
Why not?

How would you perform a fileupload with Ajax?
Submit the form to a dynamically generated (hidden) iframe (the dynamical
part is optional), and read back the upload status through an XHR request.
BTDT.
PointedEars
--
Anyone who slaps a 'this page is best viewed with Browser X' label on
a Web page appears to be yearning for the bad old days, before the Web,
when you had very little chance of reading a document written on another
computer, another word processor, or another network. -- Tim Berners-Lee
Jun 27 '08 #10
On Apr 18, 1:30*pm, Thomas 'PointedEars' Lahn <PointedE...@web.de>
wrote:
Tom Cole wrote:
On Apr 17, 10:56 am, Captain Paralytic <paul_laut...@yahoo.comwrote:
On 16 Apr, 20:30, Tom Cole <tco...@gmail.comwrote:I have a rather complicated business application that uses Ajax. Part
of this form requires uploading documents, which I cannot do using
Ajax,
Why not?
How would you perform a fileupload with Ajax?

Submit the form to a dynamically generated (hidden) iframe (the dynamical
part is optional), and read back the upload status through an XHR request.
BTDT.

PointedEars
--
Anyone who slaps a 'this page is best viewed with Browser X' label on
a Web page appears to be yearning for the bad old days, before the Web,
when you had very little chance of reading a document written on another
computer, another word processor, or another network. -- Tim Berners-Lee
That's what I am doing, I guess I was incorrect in my previous
statement. I tend to use the terms "Ajax" and "XHR" as synonyms which
I guess they are not.
I guess I meant that I could not process document uploads using XHR.
Jun 27 '08 #11
On 18 Apr, 16:29, Tom Cole <tco...@gmail.comwrote:
On Apr 17, 10:56 am, Captain Paralytic <paul_laut...@yahoo.comwrote:
On 16 Apr, 20:30, Tom Cole <tco...@gmail.comwrote:I have a rather complicated business application that uses Ajax. Part
of this form requires uploading documents, which I cannot do using
Ajax,
Why not?

How would you perform a fileupload with Ajax?
Take a look at Google Mail. When you select a file for attaching to an
email, it gets uploaded immediately in the background, whilst you are
still composing the email.
Jun 27 '08 #12
On Apr 21, 6:58*am, Captain Paralytic <paul_laut...@yahoo.comwrote:
On 18 Apr, 16:29, Tom Cole <tco...@gmail.comwrote:
On Apr 17, 10:56 am, Captain Paralytic <paul_laut...@yahoo.comwrote:
On 16 Apr, 20:30, Tom Cole <tco...@gmail.comwrote:I have a rather complicated business application that uses Ajax. Part
of this form requires uploading documents, which I cannot do using
Ajax,
Why not?
How would you perform a fileupload with Ajax?

Take a look at Google Mail. When you select a file for attaching to an
email, it gets uploaded immediately in the background, whilst you are
still composing the email.
I've noticed that when I use this form submission to an IFrame
technique, in Internet Explorer there is a little progress bar that
appears in the bottom status bar of rhe browser as if something is
still processing, even after my server send the response and my IFrame
is populated. It doesn't appear to affect anything, but is strange.
Opera, FF, Safari does not exhibit this behaviour.
Jun 27 '08 #13
On 21 Apr, 14:00, Tom Cole <tco...@gmail.comwrote:
On Apr 21, 6:58 am, Captain Paralytic <paul_laut...@yahoo.comwrote:
On 18 Apr, 16:29, Tom Cole <tco...@gmail.comwrote:
On Apr 17, 10:56 am, Captain Paralytic <paul_laut...@yahoo.comwrote:
On 16 Apr, 20:30, Tom Cole <tco...@gmail.comwrote:I have a rather complicated business application that uses Ajax. Part
of this form requires uploading documents, which I cannot do using
Ajax,
Why not?
How would you perform a fileupload with Ajax?
Take a look at Google Mail. When you select a file for attaching to an
email, it gets uploaded immediately in the background, whilst you are
still composing the email.

I've noticed that when I use this form submission to an IFrame
technique, in Internet Explorer there is a little progress bar that
appears in the bottom status bar of rhe browser as if something is
still processing, even after my server send the response and my IFrame
is populated. It doesn't appear to affect anything, but is strange.
Opera, FF, Safari does not exhibit this behaviour.
Have you checked GM in IE to see if it does this too?
Jun 27 '08 #14
On Apr 21, 10:13*am, Captain Paralytic <paul_laut...@yahoo.comwrote:
On 21 Apr, 14:00, Tom Cole <tco...@gmail.comwrote:


On Apr 21, 6:58 am, Captain Paralytic <paul_laut...@yahoo.comwrote:
On 18 Apr, 16:29, Tom Cole <tco...@gmail.comwrote:
On Apr 17, 10:56 am, Captain Paralytic <paul_laut...@yahoo.comwrote:
On 16 Apr, 20:30, Tom Cole <tco...@gmail.comwrote:I have a rather complicated business application that uses Ajax. Part
of this form requires uploading documents, which I cannot do using
Ajax,
Why not?
How would you perform a fileupload with Ajax?
Take a look at Google Mail. When you select a file for attaching to an
email, it gets uploaded immediately in the background, whilst you are
still composing the email.
I've noticed that when I use this form submission to an IFrame
technique, in Internet Explorer there is a little progress bar that
appears in the bottom status bar of rhe browser as if something is
still processing, even after my server send the response and my IFrame
is populated. It doesn't appear to affect anything, but is strange.
Opera, FF, Safari does not exhibit this behaviour.

Have you checked GM in IE to see if it does this too?- Hide quoted text -

- Show quoted text -
It appears to behave the same. And BTW it's in Firefox, not IE that is
does this. As I mentioned everything is working just fine so I'll just
leave it alone for now.
Jun 27 '08 #15

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: mike | last post by:
ok here's the problem: I have a page that displays a form for user to select individual fields and to specify their own criteria which is used to query a database and then create an excel...
4
by: Federico Bari | last post by:
Good morning all from italy, i have probably a compatibility problem with a html/javascript page. The aim of the code of the file test.htm you find here following (copy the 3 files in the...
11
by: Ed Blinn | last post by:
Can someone tell me where the problem here is? I can't get the "squared()" function to work properly...it supposed to put the squared value into the iframe area. Thanks, Ed <!DOCTYPE HTML...
1
by: Ed Blinn | last post by:
Can someone tell me why this script will only work on a Mac with Internet Explorer. Thanks, Ed <html> <head> <script type="text/javascript"> //Square Root
4
by: Thomas | last post by:
Hi there, I have an iframe which is editable (designMode = "on") and want to resize it dynamically as the content grows (e.g. more lines of text is in there) and there the struggle starts. I...
9
by: cakewalkr7 | last post by:
We have a form that contains an iframe. In the iframe are 3 select boxes (country, state and city). When you select the country, the iframe page refreshes with the appropriate states and does the...
2
by: mike | last post by:
I have a page with a form as follows: <form name="updfrm" method="post" action="update_db.cfm"> <input type="text" name="myfield" value="stuff"> <button onclick="sub_this();">press here</button>...
1
by: gzannd | last post by:
I have a problem with submitting a form to a PHP page through a dynamically created IFRAME in IE7. This code works fine in Firefox. However, IE7 submits an empty form--the correct PHP page is...
1
by: XP | last post by:
Hello Everyone, I was stuck with this really frustrating problem for sometime. Let me explain what I am trying to achieve: There is a form and an inner iframe. The form's target is set to the...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.