I would recommend using jquery, ajax (XMLHttpRequest). Iframes are old, not semantic, and you cannot access the iframe in main.php.
$("#submit_button_id").click(function(e) { e.preventDefault(); $.post('form.php', $("#form_name").serialize(), function(result) { $("#div_id").html(result); } }
this fragment should work.
$("#submit_button_id").click(function(e) { : catches the click function of the assigned identifier and creates a trigger.
e.preventDefault(); : prohibits form submission regularly; we will submit it via jquery.
$.post submits the form to the POST method.
'form.php' is your form controller that will return the displayed html code.
("#form_name").serialize() This function is a utility for serializing the form to submit. it loads the input fields and converts them as { field1: value, field2: value }
function(result) { is the third parameter; if successful, $.post calls the 3rd parameter as a function. we create an anonymous function to replace the html of our div.
$("#div_id").html(result) sets the assigned html div to the result variable.
refer to http://api.jquery.com/ , they have a wonderful reference sheet.
Umur Kontacı
source share