8
Can anyone explain to me if you have a problem playing a function for the variable, for example, in this case I’m talking about the var marcar
.
In this code is working, I don’t know if it causes a performance loss or something. The marcar
will only run at the moments that 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();
}
});
There is no problem, Marcelo.
– Victor