Change src from iframe and post date with javascript

1

I have a script where I change the src of the iframe by java script (it has to be by this methodo), but I do not know how to send data by post only by get as it is only by the data in the url someone knows how to do this

<div id="overlayedt" >
    <iframe id="frameEditor" src="" style="position:absolute;width:100%;height:100%;background:white"></iframe>
</div>

Java script

function editfile(a,b,c){
    $("#frameEditor").attr('src','<?php echo $s; ?>/manager/editor/?a='+a+'&b='+b+'&c='+c+'',{aa:'oii'});
    $("#overlayedt").show();
}

I've already tried posting the data via post with {key:value} equal to $.post() but nothing

    
asked by anonymous 06.07.2016 / 03:23

1 answer

3

Here is a very simple example of how to send a POST to iframe :

HTML

<form id="formulario" action="http://httpbin.org/post" method="post" target="destino">
  <input type="hidden" id="campo" name="campo">
</form>
<iframe name="destino"></iframe>

JS

setInterval ( function(){
  document.getElementById("campo").value = Date();
  document.getElementById("formulario").submit();
}, 2000 );

See working at CODEPEN .

I used the date in the field as an example, to change the src and any other field, the logic is the same.

    
06.07.2016 / 03:52