How to pass input field data via post to fancybox iframe page

3,768 views
Skip to first unread message

DMC

unread,
Jan 21, 2011, 8:36:32 AM1/21/11
to fancybox
I'm able to pass input field data to the email.php page via query
string (i.e. email.php?to=), however, I can't figure out how to pass
the input form data via post to the iframe page. Can someone please
help.

Here is the query string approach that works ....

$('#form').submit( function() {
var sData = $('input', oTable.fnGetFilteredNodes()).serialize();

$.fancybox({
'padding' : 10,
'autoScale' : false,
'transitionIn' : 'fade',
'transitionOut' : 'fade',
'title' : this.title,
'width' : 680,
'height' : 495,
'href' : 'email.php?to='+ escape(sData),
'type' : 'iframe'
});

return false;
} );

here is my form ...

<form id=\"form\" action=\"email.php\" method=\"post\">";
<INPUT type=\"text\" id=\"userList\" name=\"userList\" size=\"100\"
value=\"test\" >";
<input type=\"submit\" value=\"Send Email\">";

DMC

unread,
Jan 22, 2011, 7:01:14 PM1/22/11
to fancybox
This works but I'd rather open the window in an iframe. Can you send
post data to an iframe?


$("#form").bind("submit", function() {

$.fancybox.showActivity();

$.ajax({
type : "POST",
cache : false,
url : "email.php",
data : $(this).serializeArray(),
success: function(data) {
$.fancybox(data);
}
});

return false;
});

Alexandru-Bogdan Iatan

unread,
Oct 4, 2013, 8:43:23 AM10/4/13
to fanc...@googlegroups.com, davidm...@gmail.com
Why don't you use get in stead of post?

$(function() {
$('#some-id').click(function() {
$.fancybox({
'width': '60%',
'height': '80%',
'autoScale': true,
'transitionIn': 'fade',
'transitionOut': 'fade',
'href': '/email.php?some_name=$some_var&other_name=$other_name....etc...', // if you don't have more than one, just write ''/email.php?some_name=$some_var'
'type': 'iframe'
});
return false;
});
});

//email.php

<?=$_GET['some_name']?> // put this in the place you what the variable to be put

Jan Wilson

unread,
Oct 4, 2013, 9:21:46 AM10/4/13
to fanc...@googlegroups.com
But PLEASE, don't insert a $_GET variable (or even a $_POST variable,
actually) into a page without validating it. User input should ALWAYS be
viewed as potentially dangerous.

--
Jan Wilson
Reply all
Reply to author
Forward
0 new messages