我有一个使用Ajax的相当复杂的业务应用程序。部分此表格的需要上传文件,我无法使用 Ajax,所以我将表格发布到IFrame。这部分工作正常。 我遇到的问题是我的服务器进程将一些内容返回到IF $以完成表单处理并报告任何错误 可能已经发生了。这里有一个可以回写的例子: < html> < head> < ; script type =" text / javascript"> 函数已完成(){ window.parent.reportsCompleted(); } < / script> < body onload =" completed();"> < error>该文件类型.doc不受支持。< / error> < / body> < / html> 现在这可以正确调用父 帧的reportsCompleted方法。我遇到的问题是读取任何< error> 标记的内容(如果存在): 函数reportsCompleted(){ var frame = frames [''upload_frame'']; if(frame.document.getElementsByTagName(" error")。leng th 0){// 有错误... var message ="发生以下错误:" ;; for(var i = 0; i< frame.document.getElementsByTagName(" error")。lengt h; i ++){ message + =" \ n" + frame.document.getElementsByTagName(" error")[i] .nodeValue(); } alert(message); } } 问题是我从来没有得到错误标签的内容 显示。我只看到一个警告窗口,上面写着发生以下 错误:。 我做错了什么?
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?
推荐答案4月16日下午3:30 *,Tom Cole< tco ... @ gmailwrote: On Apr 16, 3:30*pm, Tom Cole <tco...@gmailwrote: 我有一个使用Ajax的相当复杂的业务应用程序。部分此表格的需要上传文件,我无法使用 Ajax,所以我将表格发布到IFrame。这部分工作正常。 我遇到的问题是我的服务器进程将一些内容返回到IF $以完成表单处理并报告任何错误 可能已经发生了。这里有一个可以回写的例子: < html> < head> < ; script type =" text / javascript"> 函数已完成(){ * * window.parent.reportsCompleted();} < / script> < body onload =" completed();"> < error>文档类型。 doc不受支持。< / error> < / body> < / html> 现在这个是否正确调用了父 帧的reportsCompleted方法。我遇到的问题是读取任何< error> 标记的内容(如果存在): 函数reportsCompleted(){ * * var frame = frames [''upload_frame'']; * * if(frame.document.getElementsByTagName(" error")。leng th 0){// 有错误... * * * * var message ="发生以下错误:" ;; * * * * for(var i = 0; i< frame.document.getElementsByTagName(" error")。lengt h; i ++){ * * * * * * message + =" \ n" + $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ * * *提醒(留言); * *} } 问题是我从不获取错误标签的内容 显示。我只看到一个警告窗口,上面写着发生以下 错误:。 我做错了什么? 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?
为什么不使用.innerHTML而不是你不存在的.nodeValue()? developer.mozilla/en/docs...ment.nodeValue
Tom Cole写道: Tom Cole wrote: [...] 我遇到的问题是我的服务器进程返回一些内容,以便完成表单处理并报告 可能发生的任何错误。这里有一个可以回写的例子: < html> < head> < ; script type =" text / javascript"> 函数已完成(){ window.parent.reportsCompleted(); } < / script> < body onload =" completed();"> < error>该文件类型.doc不受支持。< / error> < / body> < / html> [...]我遇到的问题是阅读任何< error> 标记的内容(如果存在): function reportsCompleted(){ var frame = frames [''upload_frame'']; if(frame.document.getElementsByTagName(" error")。leng th 0){// 有错误... [...] 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...
请改用: if(frame) { //在这里添加功能测试 var c = frame.document.getElementsByTagNa我(错误); var len = c.length; if(len 0) {
Use instead: if (frame) { // add feature test here var c = frame.document.getElementsByTagName("error"); var len = c.length; if (len 0) {
var message ="发生以下错误:" ;; for(var i = 0;我< .length; i ++){ var message = "The following error(s) occured:"; for (var i = 0; i < .length; i++) {var message = []; for(var i = 0; i< len; i ++ ) {
var message = []; for (var i = 0; i < len; i++) {
message + =" \ n" + frame.document.getElementsByTagName(" error")[i] .nodeValue(); message += "\n" + frame.document.getElementsByTagName("error")[i].nodeValue();message.push(c [i] .nodeValue;
message.push(c[i].nodeValue;
} alert(消息); } alert(message);} window.alert(message.join(" \ n" ));
} 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?使用非 - 应该是HTML文档中的-HTML元素, 并且调用属性虽然它不是方法。 jibbering/faq/#FAQ4_43 validator.w3/ PointedEars - 任何拍下这个页面的人最好用浏览器X'标签查看 a网页似乎渴望过去的糟糕时光,在网络之前,当你几乎没有机会阅读另一台b / b 计算机上写的文件时,另一个字眼就是处理器或其他网络。 - Tim Berners-Lee
Using non-HTML elements in a supposed-to-be HTML document, and calling a property although it is not a method. jibbering/faq/#FAQ4_43 validator.w3/ 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
< erroris不是标准的HTML元素,然后不同的浏览器在unknow标签上有不同的行为 不同的行为 对于IE,你应该为自定义元素定义命名空间 (xmlns:my =" http://xxxx...."然后使用我的:错误,然后使用 document.getELementsByTagName("错误")) for Firefox,你不需要定义命名空间,但你必须写 document.getElementsByTagName(" my:error"); 最好使用标准的HTML元素(p,span)和innerHTML。 4月17日凌晨2点30分,Tom Cole< tco ... @ gmailwrote: 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="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...@gmailwrote: 我有一个相当复杂的业务应用程序使用Ajax。部分此表格的需要上传文件,我无法使用 Ajax,所以我将表格发布到IFrame。这部分工作正常。 我遇到的问题是我的服务器进程将一些内容返回到IF $以完成表单处理并报告任何错误 可能已经发生了。这里有一个可以回写的例子: < html> < head> < ; script type =" text / javascript"> 函数已完成(){ * * window.parent.reportsCompleted();} < / script> < body onload =" completed();"> < error>文档类型。 doc不受支持。< / error> < / body> < / html> 现在这个是否正确调用了父 帧的reportsCompleted方法。我遇到的问题是读取任何< error> 标记的内容(如果存在): 函数reportsCompleted(){ * * var frame = frames [''upload_frame'']; * * if(frame.document.getElementsByTagName(" error")。leng th 0){// 有错误... * * * * var message ="发生以下错误:" ;; * * * * for(var i = 0; i< frame.document.getElementsByTagName(" error")。lengt h; i ++){ * * * * * * message + =" \ n" + $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ * * *提醒(留言); * *} } 问题是我从不获取错误标签的内容 显示。我只看到一个警告窗口,上面写着发生以下 错误:。 我做错了什么? 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?
更多推荐
将表单发布到IFrame的问题
发布评论