Get data from a form that is in an iframe

I would like to get my form data that is in an iframe in my main form with $ _POST, maybe?

This is the contents of my iframe:

<form method="post" action="demo.html"> <div class="col-md-12 nopadding"> <textarea id="txtEditor"></textarea> </div></form> 

This iframe is included in my main form.

I tried this but did not work:

 <iframe name="contenuArticle" onload="copyIframeContent(this);" src="<?php echo $base_url.'/wysiwyg/demo.html"'; ?> scrolling="no" height="424.4" width="770" FRAMEBORDER="no"></iframe> <script>$('#contenuArticle').contents().find('#txtEditor').html(); </script> <textarea id="recup"></textarea> 

I also tried this:

  <iframe name="contenuArticle" id="contenuArticle" src="<?php echo $base_url.'/wysiwyg/demo.html"'; ?> scrolling="no" height="424.4" width="770" FRAMEBORDER="no"></iframe> <script>document.getElementById("#contenuArticle").innerHTML; </script> 

And this:

 <iframe name="contenuArticle" id="contenuArticle" src="<?php echo $base_url.'/wysiwyg/demo.html"'; ?> scrolling="no" height="424.4" width="770" FRAMEBORDER="no"></iframe> <script>document.getElementById('#contenuArticle').contentWindow.document.body.innerHTML;</script> 

And this:

 <script> $('input:button[name=publier]').click(function() { var name = $('iframe[name=contenuArticle]').contents().find('#txtEditor').val(); }); 

Thank you in advance for your help.

+5
source share
1 answer

You are trying to get content before downloading it.

try it

 $(document).ready(function(){ $('#iframe').on('load', function () { console.log($(this).contents().find('#txtEditor').val()); }); }); 

he works for me.

0
source

Source: https://habr.com/ru/post/1262060/


All Articles