0
I never worked with ajax but I need in a form do a search on MySQL
to check if the login that the user is typing already exists.
In the input field I put a onBlur
for when the guy jumps from the field the system check if there is that login.
Like I’ve got a model on the net but it’s incomplete what I do next?
function TestaLogin(){
$.ajax({
url: 'VerificaDados.php',
type: 'POST',
dataType:'json',
data: {"Cpf" : $("#cpf").val()},
success: function(data) {
/*** Não faz nada pois está ok*/
}
});
}
What do I do now on the PHP side? How do I get this variable? Search the bank I know, mount the SQL
quiet, but how I return an answer to
app and if it is not positive like there is that login what I put next to the javascript
to signal that there is?
Do as you normally do,
$_POST['cpf']
, to return just oneecho 'sucesso ou falha';
or you can send a json.– rray
add an error: Function(data) { Alert(data); }. You have to check two things: If the name and path of the.php file is correct and it is actually returning a JSON.
– alan