Can anyone explain to me if I have a problem while playing a function for the variable, for example, in this case I'm talking about var marcar
.
This code is working, I do not know if it causes a performance loss or something else. Will marcar
only run at the times when it will actually run correctly?
$('input:checkbox#marcar').click(function() {
var valor_id = $(this).data('valor-id'),
checked = $(this).is(':checked');
var marcar = function() {
$.ajax({
url: 'marcar.php',
data: {'valor_id' : valor_id},
success: function()
{
alert('Sucesso!!!');
}
});
}
if(checked === false)
{
$.ajax({
url: 'verifica.php',
data: {'valor_id' : valor_id},
success: function(retorno) {
var resp = $.parseJSON(retorno);
if(resp.success === true)
{
var cont = confirm(resp.msg);
if(cont === true)
{
marcar();
}
else
{
$this.prop("checked", true);
}
}
else
{
marcar();
}
}
});
}
else
{
marcar();
}
});