I have a form that when selecting a 'select' is sent automatically by AJAX, the call works well. Now when passing the variables of the form it says Notice: Undefined index:
In the index.php file I have
function enviar(theForm) {
$.ajax({
type: "POST",
url: "a.php",
data: $(this).serialize(),
success: function(data) {
$('#a').html(data);
}
});
event.preventDefault();
};
<form role="form" name="nD" id="nD" method="post">
<select name="d" onchange="enviar(this.form)">
<option value="" disabled selected>Selecciona</option>
<option value="1">Uno</option>
<option value="2">Dos</option>
<option value="3">Tres</option>
</select>
</form>
<div id="a"></div>
In the a.php file I have
<h1>prueba</h1>
<?php echo $_POST['d'] ?>
Removing 'onchange="send (this.form)"' and placing a 'submit' works fine, but it is necessary that the form be sent when a 'select' option is selected. Thanks