0
I have one (.html), one (.php) and my jQuery.
In my jQuery( I am sending the information to (.php) do CRUD and etc.
Transactions are occurring smoothly, but are not displaying error messages of the type ("id_person field cannot be empty).
How do I do that?
$('#cadastrar').on('click', function(){
var opcaoCadastrar = $(this).attr("value");
var nome = $('#nome').val();
$.post('consulta.php',
{opcaoCadastrarEnvia:opcaoCadastrar,nomeEnviarCadastrar:nome},function(data){
});
});
if (isset($_POST['opcaoCadastrarEnvia'])){
$nome = $_POST['nomeEnviarCadastrar'];
$consulta = "INSERT INTO FUNCIONARIO (FUN_NOME)VALUES(:nome)";
$resultado->$db_con->prepare($consulta);
$resultado->BindParam(':nome',$nome,PDO::PARAM_STR);
$resultado->execute();
}
Didn’t work, still no error messages =/
– Rodrigo Caio
Let’s go in parts. Inside the post block, add console.log(date). What displays on the console?
– Lucas Torres
$('#register'). on('click', Function(){ var optionCadastrar = $(this). attr("value"); var name = $('#name'). val(); $. post('query.php', {optionCast:optionCast,nameCast:name},Function(data){ console.log(data); }); });
– Rodrigo Caio
Keep coming back nothing.
– Rodrigo Caio
This means that not even the request is being made, you need to a) see the errors that are in the console and b) access your php script directly and see the error that appears
– Lucas Torres
My script was on my index(working), but as all my other transactions were on mine (.jQuery), I decided to put it there too, it’s the only one that isn’t working. I’m sure they are by the fields not null in my database, however, I wanted these errors to be returned the same as they were in my index.
– Rodrigo Caio
If I put a Try/catch in my php, it would solve the problem?
– Rodrigo Caio
We can try :)
– Lucas Torres