jQuery form submit

By : kmunky
Source: Stackoverflow.com
Question!

i have this files:

JAVASCRIPT

$(document).ready(function(){
    $('a').click(function(){
        $('div').load("formular.html",function(){
            $('input[type="submit"]').click(function(){
                $('form').submit(); 
            });
        });
    });
});

formular.html

<form action="gigi.php" name='formular' method="post" enctype="multipart/form-data" />
    <input type="file" name="fisier" />
    <input type="submit" value="trimite" />

main html file

<a href="#">click</a>
<div></div>

PHP(gigi.php)

$nume = $_FILES['fisier']['tmp_name'];
print $nume;

what I'm trying to do is to load the formular.html on "a" click, and then to submit the imported form. BUT..if I'm not using the submit() method and I try to click the submit button...NOTHING happens (it won't load the gigi.php in the browser). Using the submit method, it looks like the form is submitted (the gigi.php is loaded in the browser) but the form data is not passed to php page (so i get the "undefined index..." error). This is an example with a file input, but I tried with text too... and it still doesn't work. SO I REALLY NEED HELP :D thanks guys

By : kmunky


Answers

Hai salut! :)

Try closing your form tag in formular.html. Oh, I now see from the other response (which arrived in the meantime) that you were actually submitting an empty form because you were closing it on the line you opened it.

By : kitsched


This video can help you solving your question :)
By: admin