Greetings community! I'm doing the following
Of the customer day with Jquery
In the next function I get an email and send it with ajax using everything right here How could I return a json array from the server and access it from JQuery?
$('#email').focusout(function(event) {
event.preventDefault();
$(function() {
var parametros = {
"email" :$("#email").val()}
$.ajax({
data: parametros,
url: 'validar_correo',
dataType: "json",
type: 'post',
beforeSend: function () {
$("#respuesta").html("Procesando, espere por favor...");
},
success: function (json) {
console.log(json);
$("#respuesta").html("");
if (json.validar_correo == true) {
$("#respuesta").html("El correo ya existe");
}
}
});
});
});
On the server side
public function validar_correo(){
$datos =Input::all();
if (condicion) {
$response = Response::json(array("validar_correo"=>True));
}else{
$response = Response::json(array("validar_correo"=>False));
}
}