Sé que esta pregunta es antigua, pero así es como lo hice en ASP.Net (C#) usando jQuery.
//Create the form in a jQuery object
$("<form action='/FormPostTo.aspx' method='post' target='nameofframe'></form>")
//Get the value from the asp textbox with the ID txtBox1 and POST it as b1
.append($("<input type='hidden' name='b1' />").attr('value',$('#<%= txtBox1.ClientID %>').val()))
//Get the value from the asp textbox with the ID txtBox2 and POST it as b2
.append($("<input type='hidden' name='b2' />").attr('value',$('#<%= txtBox2.ClientID %>').val()))
//Add the form to the body tag
.appendTo('body')
//Submit the form which posts the variables into the iframe
.submit()
//Remove the form from the DOM (so subsequent requests won't keep expanding the DOM)
.remove();
Sólo una pequeña nota: me hicieron los tags de entrada como el que en lugar de la concatenación de ellos, en caso de que el valor del cuadro de texto tenía un presupuesto ('
) en ella. Si lo concatena, arruinaría el HTML y no se analizaría correctamente.
Además, esto elimina el formulario del DOM después de que se haya utilizado, de modo que no llene el DOM con elementos de formulario si lo publica varias veces en el iFrame.
Un pequeño cambio que podría hacer, sería crear el elemento de formulario si no existe y luego simplemente hacer referencia por ID si ya existe y reutilizarlo.
Realmente no importa ajax. Todo lo que quiero es enviar una publicación a un iframe desde fuera sin que el usuario tenga que hacer clic en el botón Enviar. No puedo pasarlos al iframe utilizando el src porque no son los parámetros querystring lo que quiere. La etiqueta