Hello together.
I''m trying to call an Ajax.Updater from within an IFrame to update an
element in the parent window.
It is working, but I receive an error from Firefox when I do so.
What I want to do is to upload a file, and then after the file has
completed uploading, automatically reload a section of the page with
information about the file to post-process it.
However, AJAX doesn''t like file uploads, so my only choices are the
(hidden) IFrame approach or a flash/perl/whatever scenario, which
seems too much for the simple task I''m trying to achieve.
This is the code I''m using (simplified, but same functionality):
function doMyFancyUpdate()
{
// myUpdateID is within the parent frame
var myID = top.document.getElementById(''myUpdateID'');
var myURL = ''showfile.php'';
new Ajax.Updater(
myID,
myURL,
{
method: ''post'',
onException: function(ele, ele2) { alert("Error!\n" + ele2.message
+"\n"+ ele2.fileName +"\nLine:"+ ele2.lineNumber); }
}
);
}
In the IFrame itself I am simply calling a <script>doMyFancyUpdate();</
script>. And these are the error messages I receive:
With the alert command:
[Exception... "Component returned failure code: 0x80004005
(NS_ERROR_FAILURE) [nsIDOMWindowInternal.alert]" nsresult:
"0x80004005 (NS_ERROR_FAILURE)" location: "JS frame ::
functions.js :: anonymous :: line 752" data: no]
Line 752 would be the alert part of the function
When I commented out the alert command within onException:
Ajax is not defined
prototype.js
Line 1352
"Ajax.Responders.dispatch(''onException'', this,
exception);"
And finally when I removed the onException part entirely:
Prototype is not defined
prototype.js
Line 1351
"(this.options.onException || Prototype.emptyFunction)(this,
exception);"
When I directly call an Ajax.Updater within the IFrame, without a
functional reference, I receive the third error. The update itself is
still working though.
Setting myID to only ''myUpdateID'' doesn''t work, it
doesn''t update
anything at all, although it does call the updater (I assume that it
tries to find the ID within the IFrame and update this one, which of
course doesn''t exist there).
I searched the net a bit and found this site:
http://www.fleegix.org/articles/2006/10/21/xmlhttprequest-and-0x80004005-ns_error_failure-error
I tried the solution posted there (created a dummy function that calls
my real function), but it didn''t help at all.
So, is there any solution or workaround? Did anybody try something
similar already?
In IE6 it seems to work fine, at least I don''t receive an error.
Thank you for your help,
Robert
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---
You need to call: parent.doMyFancyUpdate(); ...since you are talking to the parent frame and not the frame that completed the upload. On Jan 1, 9:32 am, Robert <spoon...-hi6Y0CQ0nG0@public.gmane.org> wrote:> Hello together. > > I''m trying to call an Ajax.Updater from within an IFrame to update an > element in the parent window. > It is working, but I receive an error from Firefox when I do so. > What I want to do is to upload a file, and then after the file has > completed uploading, automatically reload a section of the page with > information about the file to post-process it. > However, AJAX doesn''t like file uploads, so my only choices are the > (hidden) IFrame approach or a flash/perl/whatever scenario, which > seems too much for the simple task I''m trying to achieve. > > This is the code I''m using (simplified, but same functionality): > > function doMyFancyUpdate() > { > // myUpdateID is within the parent frame > var myID = top.document.getElementById(''myUpdateID''); > var myURL = ''showfile.php''; > > new Ajax.Updater( > myID, > myURL, > { > method: ''post'', > onException: function(ele, ele2) { alert("Error!\n" + ele2.message > +"\n"+ ele2.fileName +"\nLine:"+ ele2.lineNumber); } > } > ); > > } > > In the IFrame itself I am simply calling a <script>doMyFancyUpdate();</ > script>. And these are the error messages I receive: > > With the alert command: > [Exception... "Component returned failure code: 0x80004005 > (NS_ERROR_FAILURE) [nsIDOMWindowInternal.alert]" nsresult: > "0x80004005 (NS_ERROR_FAILURE)" location: "JS frame :: > functions.js :: anonymous :: line 752" data: no] > Line 752 would be the alert part of the function > > When I commented out the alert command within onException: > Ajax is not defined > prototype.js > Line 1352 > "Ajax.Responders.dispatch(''onException'', this, exception);" > > And finally when I removed the onException part entirely: > Prototype is not defined > prototype.js > Line 1351 > "(this.options.onException || Prototype.emptyFunction)(this, > exception);" > > When I directly call an Ajax.Updater within the IFrame, without a > functional reference, I receive the third error. The update itself is > still working though. > > Setting myID to only ''myUpdateID'' doesn''t work, it doesn''t update > anything at all, although it does call the updater (I assume that it > tries to find the ID within the IFrame and update this one, which of > course doesn''t exist there). > > I searched the net a bit and found this site:http://www.fleegix.org/articles/2006/10/21/xmlhttprequest-and-0x80004... > I tried the solution posted there (created a dummy function that calls > my real function), but it didn''t help at all. > > So, is there any solution or workaround? Did anybody try something > similar already? > In IE6 it seems to work fine, at least I don''t receive an error. > > Thank you for your help, > Robert--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
D''oh! Thank you, that worked. And moreover, it is also logical. :-) On 2 Jan., 19:26, Diodeus <diod...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> You need to call: parent.doMyFancyUpdate(); > > ...since you are talking to the parent frame and not the frame that > completed the upload.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---