jquery form send only element into data: attribute
Sorry I have a problem, i have this form
<form id="main_form" name="main_form" enctype="multipart/form-data" method="post">
<div class="content">
<ul>
<li>
<h3>Cognome</h3>
<input type="text" id="main_cognome" size="20" maxlength="30" />
</li>
<li>
<h3>Nome</h3>
<input type="text" id="main_nome" size="20" maxlength="30" />
</li>
<li>
<h3>Codice fiscale</h3>
<input type="text" id="main_cf" size="20" maxlength="19" />
</li>
<li>
<h3>Comeptenza</h3>
<?php
echo "<select id=\"main_competenza\" >";
while ($row_competenza = mysql_fetch_assoc($result_competenza)) {
echo "<option value=\"".$row_competenza['id']."\">";
echo $row_competenza['desc']."</option>";
}
echo "</select>";
?>
</li>
<li>
<h3>Tipologia</h3>
<?php
echo "<select id=\"main_tipologia\" >";
while ($row_tipologia = mysql_fetch_assoc($result_tipologia)) {
echo "<option value=\"".$row_tipologia['id']."\">";
echo $row_tipologia['desc']."</option>";
}
echo "</select>";
?>
</li>
<li>
<h3>Allegati</h3>
<input type="file" id="main_file" />
</li>
<li>
<h3>Inserisci Medico</h3>
<input id="inviaMedico" type="submit" value="invia" title="Se il cognome e il nome del medico sono giá presenti in lista verrá aumentato il numero di inadempienze anziché inserire una riga nuova" />
</li>
</ul>
</div>
</form>
whene try to send this form with
$(document).ready(function () {
$('#main_form').submit(function() {
$(this).ajaxSubmit({
target: "#medici", // target element(s) to be updated with server response
beforeSubmit: function(formData, jqForm, options) {
var form = jqForm[0];
if (!form.main_cognome.value || form.main_cognome.value=="") {
$('#stato').html('errore : devi almeno inserire il cognome del medico').slideDown("slow").delay(2000).slideUp("slow");
$("#main_cognome").css('border', '1px dotted #c30');
return false;
}
}, // pre-submit callback
success: function(responseText, statusText, xhr, $form) {
if($('#medicicc')) $('#medicicc').load('php/medicicc.php');
$("#main_cognome").css('border', 'solid 1px #009752');
$("input:file").MultiFile("reset");
alert( $form.attr('id') );
}, // post-submit callback
url: "php/medici.php", // override for form's 'action' attribute
clearForm: true
});
return false;
});
});
the php page with
foreach($_POST as $var => $value)
{
echo $var . ' : ' . $value . "<br>";
}
foreach($_FILES as $file) {
$n = $file['name'];
$s = $file['size'];
echo "File: $n ($s bytes)";
}
obtain nothing
if try to add attribute data : { field:value} in $_POST obtain a element!
Why I can't get element form if don't use data attribute?
please help me