Hi, I have the following function of jquery
(function ($) {
$.onlyData = function (id) {
var respuesta;
var datos =$(id).data("sql");
datos=datos.split("-")
var campoBD = datos[0];
var tableModel = datos[1];
var arr = $(id).val();
var parametros = {
"Field": {
"Data": arr
}
};
$.ajax({
data: parametros,
url: '/Desarrollo/consultar_existencia/' + campoBD + "/" + tableModel,
type: 'post',
dataType: "json",
success: function (response) {
console.log(response);
respuesta=(response);
},
error: function (jqXHR, textStatus, errorThrown) {
console.log(jqXHR);
}
});
return "chap"+respuesta;
}
})(jQuery);
And when I click on a button
enter here:
var unico = 0;
alert($.onlyData("#" + $(".txtEmail").attr("id")));
but the alert arrives like this:
and I need the ajax response for a validation and the thing is that the console if it shows bn the response: