Access elements of parent window from iframe?

Have the below js inside the iframe and use ajax to submit the form.

Have the below js inside the iframe and use ajax to submit the form. $(function(){ $("form"). Submit(e){ e.preventDefault(); //Use ajax to submit the form $.

Ajax({ url: this. Action, data: $(this).serialize(), success: function(){ window.parent. $("#target").

Load("urlOfThePageToLoad"); }); }); }); }).

It works to submit the form through ajax, but the target div remains as it is from the beginning. It seems as it doesent work to communicate with parent. Php from within the iframe.

– Paparappa Aug 11 at 15:32 If the iframe is in the same domain then you will not have any issues. Can you try to alert window.parent. $("#target").

Length in the success handler. – ShankarSangoli Aug 11 at 15:40 the iframe is in the same domain. Well I put that code in instead of window.parent.

$("#target"). Load("urlOfThePageToLoad"); but it returned nothing. Where it sais "form" in your code, is it supposed to be the name of the form?

Could that be it? – Paparappa Aug 11 at 15:55 What is the name of the form? Put is as formname=nameOfYourform in place of form – ShankarSangoli Aug 11 at 16:01 check my first post, ive edited how ive done.

– Paparappa Aug 117 at 7:25.

I think you can just use window. Parent from the iframe. Window.

Parent returns the window object of the parent page, so you could do something like: window.parent.document. GetElementById('yourdiv'); Then do whatever you want with that div.

– Paparappa Aug 11 at 14:53 $(document). Ready(function(){ window.parent.document. GetElementById('#target'); $("#target").

Load("file. Php"); }); – Paparappa Aug 11 at 14:54 Probably more like: $(document). Ready(function() { $(window.parent.document.

GetElementById("target")). Load("file. Php")); }); – hardcodedid Aug 11 at 15:07 Im afraid this doesent work.

The form gets submitted well but nothing happens to the target div. It remains as it is.Hmm.. – Paparappa Aug 11 at 15:18 Probably need to keep the form from submitting until the javascript that you want to run from the iframe finishes submitting.So it would be something like (sorry if there are mistakes in the code below, writing it in a code block like this is a pain): $(;"form"). Submit(function(e){ e.

PreventDefault; window.parent.document. GetElementById('#target'); $("#target"). Load("file.

Php", function() { $('form').submit(); }); }) – hardcodedid Aug 11 at 15:56.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions