Problem sending form data with Ajax

0

Friends please help me to identify my problem I am using ajax to send the data that I extract from the form, I do not know if it is the libraries I am calling them wrong? or is it the structure of the ajax, can someone tell me what I'm doing wrong ?. Thank you.

My libraries inside the head

<link rel="stylesheet" href="../Recursos/css/bootstrap.css">
    <link rel="stylesheet" href="../Recursos/css/styles_2.css">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

My libraries below the before closing the body tag

<script src="../Recursos/js/jquery-3.3.1.js "> </script>
    <script src="../Recursos/js/jquery-3.3.1.min.js"> </script>
    <script src="../Recursos/js/popper.min.js" ></script>
    <script src="../Recursos/js/bootstrap.js"></script>

And finally I add my functions.js

<script src="Scripts/validar_form.js"></script>
    <script src="Scripts/enviar_data_form.js"></script>  
    <script src="Scripts/functions.js"></script>

My ajax:

$.ajax({
            type:"POST",
            url:"localhost/Proyecto_AIUP/Ubicacion/Verificacion/Validar_Entrada.php",
            data:{ matricula:js_matricula, nombre:js_nombre, apellido_pa:js_apellido_pa, apellido_ma:js_apellido_ma, id_carrera: js_carrera},
            dataType:"jsonp",
            jsonp:"jsoncallback",
            crossDomain: true,
            cache: false,
            success: function(data){
              if(data.estado=="insertado"){
                  alert("Muy bien");
                }else{
                  alert("Por favor inserte datos validos.");
                }
            }
      });
          return false;
    };

I have this at the end of the .php:

if($sentencia->execute()){
        $id= $sentencia->insert_id;
        $datos["estado"] = "insertado";
        $datos["Id"] = $id;
        //printf ("Nuevo registro con el id %d.\n", $sentencia->insert_id);


        //$totalInsert=$sentencia->affected_rows;  
        //$mensaje=($totalInsert > 0) ? "Se ha insertado correctamente" : "No fue posible la inserción. Error: ".$sentencia->error;  
        //$arrResult['mensaje'] = $mensaje;
        header("location: ../Cuestionario/cuestionario.php");
        include_once('../Cuestionario/cuestionario.php');


    }else{

        $datos["estado"] = "error";
        $datos["Id"] = null;
    }

    $stmt->close();
    $conexion->close();

    $resultadoJson = json_encode($datos);
    echo $_GET['jsoncallback'] . '(' . $resultadoJson . ');';

And why does the id appear in the search engine when I send form data ???

    
asked by Diegos Sánchez 15.07.2018 в 23:07
source

0 answers