estoy haciendo un insert into con PDO usando js, los datos se guardan bien en la base de datos pero no sé porque no me entra a function succes() y no me muestra el mensaje. Cuando hago un print_r($insert->errorInfo()); me muestra Array ( [0] => 00000 [1] => [2] => ). Lo revisé y he buscado documentacion y no encuentro el error.
Lo que quiero es que si se está guardando el base de datos me muestre el mensaje de "El registro ha sido guardado correctamente."
if (isset($_POST['Nombre']))
{
include_once('conexion.php');
try {
$now = date("Y-m-d H:i:s");
$conexion = DB::conectar();
$insert = $conexion->prepare("INSERT INTO Solicitud (NombreEmpresa, Nombre, Apellido, Email, Telefono, SitioWeb, TipoPlan, PaisID, FechaSolicitud, FechaProcesandoDemo, Activo) VALUES ( :NombreEmpresa, :Nombre, :Apellido, :Email, :Telefono, :SitioWeb, :TipoPlan, :PaisID, :FechaSolicitud, :FechaProcesandoDemo, :Activo )");
$insert->bindValue('NombreEmpresa',$_POST['NombreEmpresa']);
$insert->bindValue('Nombre',$_POST['Nombre']);
$insert->bindValue('Apellido',$_POST['Apellido']);
$insert->bindValue('Email',$_POST['Email']);
$insert->bindValue('Telefono',$_POST['Telefono']);
$insert->bindValue('SitioWeb',$_POST['SitioWeb']);
$insert->bindValue('TipoPlan',$_POST['TipoPlan']);
$insert->bindValue('PaisID',$_POST['PaisID']);
$insert->bindValue('FechaSolicitud',$now);
$insert->bindValue('FechaProcesandoDemo','0000-00-00 00:00:00');
$insert->bindValue('Activo',1);
$insert->execute();
print_r($insert->errorInfo());
} catch (PDOException $e) {
echo $e->getMessage();
}
}else{}
y este es el código js:
jQuery(document).on('click', '#btnSolicitar', function (event){
var msj = jQuery('#msj');
var btnself = jQuery('#btnSolicitar');
var dataForm = jQuery('#frmSolicitud').serialize();
$.ajax({
url: '/solicitar.php',
cache: false,
type: 'POST',
data: dataForm,
dataType: 'json',
beforeSend: function ()
{
btnself.prop('disabled', true);
wrapperContent(msj,'<div class="alert alert-warning" role="alert">Por favor espere, procesando datos.</div>');
hiddenTimeLayer(msj, 5000);
console.log("error1");
},
success: function() {
// $("#msj").html('Correcto');
wrapperContent(msj,'<div class="alert alert-success">El registro ha sido guardado correctamente.</div>');
hiddenTimeLayer(msj, 5000);
console.log("error2");
},
error: function(xhr,ajaxOptions,thrownError)
{
wrapperContent(msj,'<div class="alert alert-danger">AJAX: Ocurrió un problema (<strong>' + thrownError + ')</strong> de comunicación al solicitar su petición, por favor intente nuevamente, sí el problema persiste contacte con el Administrador.</div><div class="divider15"></div>');
btnself.removeProp('disabled',true);
console.log("error3");
}
});
});
Por favor, si encuentran algún error o alguna idea comentarla. Estaré pendiente. No sé si sea error de codigo o el insert no lo estoy haciendo bien. Gracias.