Ajax succes working but not sending data to mysql database on.click fuction and not working completely with on.submit
<p>My problem is that when i click the submit button while i have a on.('click') on top of my jquery ajax, succes works but doesn't send information to my database. Otherwise when i have on.('submit') on top of my jquery the ajax doesn't work but PHP does.</p>

<p>here is the code of my form.</p>

<pre><code>&lt;div id="seccion_registro"&gt;
&lt;div id="login_error"&gt;Campo no valido!&lt;/div&gt;
&lt;div id="registro_succes"&gt;&lt;/div&gt;


            &lt;form id="form2" name="form2" action="usuario.php" method="POST"&gt;
                &lt;label for="nombre"&gt;Nombre&lt;/label&gt;
                &lt;input id="nombre"type="text" class="text" size="20" name="nombre"&gt;

                &lt;label for="usuario"&gt;Usuario&lt;/label&gt;
                &lt;input id="password1" type="text" class="text" size="20" name="usuario"&gt;

                &lt;label for="contrasena"&gt;Contraseña&lt;/label&gt;
                &lt;input id="password1" type="password" class="text" size="20" name="contrasena"&gt;

                &lt;label for="confirmar"&gt;Confirmar contraseña&lt;/label&gt;
                &lt;input id="password2" type="password" class="text" size="20" name="confirmar"&gt;

                &lt;label for="email"&gt;Email&lt;/label&gt;
                &lt;input type="text" class= "text" size="20" name="email"&gt;

        &lt;div&gt;
                &lt;input type="submit" class="boton1" value="Regístrate" size="56"&gt;
        &lt;/div&gt;
 &lt;/form&gt;
</code></pre>

<p>This is my jquery ajax function, i use a fancybox to display the form and a succes or error response.</p>

<pre><code>$(document).ready(function(){   

$('.boton1').on('click', function(e){


e.preventDefault();

var name = $('#nombre').val();
var password1 = $('#password1').val();
var password2 = $('#password2').val();
var errors = '';

if(name.length &lt; 5 || name == ''){
errors += '&lt;p&gt;tsads&lt;/p&gt;'; 
} 




if(errors != ''){    
$("#login_error").show();       
$.fancybox.resize();

//$("#login_succes").hide();

} else {
var datos = $('#form2').serialize();
$.ajax({
    url:'Usuario.php',
    data:'datos',
    type:'POST',
    beforeSend: function(){
          $('#seccion_registro').html('&lt;div id="carga" style="margin:0 auto;width:auto;background-position:center center;"&gt;&lt;/div&gt;');
        },
    success: function(){
         $('#seccion_registro').html('&lt;p class="text_enhorabuena"&gt;Enhorabuena, has sido registrado!&lt;/p&gt;');
        $("#registro_succes").show();       
        $.fancybox.resize();
}
 });

 }



 });
</code></pre>

<p>And finally this is my php script.</p>

<pre><code>&lt;?php

include 'conexion.php';

$_POST['nombre'];
$_POST['usuario'];
$_POST['contrasena'];
$_POST['email'];

$consulta = "INSERT INTO usuario (Usuario, password, email, nombre ) VALUES ('".$_POST['usuario']."', 
  '".$_POST['contrasena']."', '".$_POST['email']."', '".$_POST['nombre']."')";


if (!mysqli_query($conexion,$consulta))
  {
      die('Error: ' . mysqli_error($conexion));
  }
else{

//Do stuff

};
mysqli_close($conexion);

?&gt;
</code></pre>
