I cannot recover the value of the updated date attribute

Asked

Viewed 41 times

0

I have an attribute date equal to 1, I update that it turns 2 however when returning it continues bringing 1.

The code that makes the update would be this :

$('[data-linha='+ cod_sacado + '] a').attr("data-status",status);

Where my cod_sacado comes from:

var cod_sacado = $(codigo).data("cod");

Example :

It does the update correctly however while trying to return the updated value, it brings me the old and not updated.

function bloquearSacado(codigo) {

    var status = "";

    var cod_sacado = $(codigo).data("cod");

    var status = $(codigo).data("status");

    if(status == "1") {
        removeAttr("data-status");
        Attr("data-status");
        var status = "2";
    } else {
        var status = "1";
    }


    $.ajax({
        url: base_url+'painel/sistema/bloquearSacado',
        type: 'POST',
        data: {cod_sacado:cod_sacado, status:status},
        dataType : 'json',
        success: function(data){
            if(data.success == true) {
                if(status == 2) {
                    $('[data-linha='+ cod_sacado + '] a svg use').attr('href','#close_menu');
                    $('[data-linha='+ cod_sacado + '] a').css("background-color","red");
                    msgOk("Alterado com Sucesso");
                } else if(status == 1) {
                    $('[data-linha='+ cod_sacado + '] a').css("background-color","green");
                    $('[data-linha='+ cod_sacado + '] a svg use').attr('href','#ok');
                    $('[data-linha='+ cod_sacado + '] a').attr("data-status",status);
                    msgOk("Alterado com Sucesso");
                }
                else {
                    alert("lala");
                }

            } else {
                msgOk("Falha ao mudar! Atualize a página");
            }
        }
    });
}
  • It would show what the date returns?

  • If it is active my link it returns 1, when I change to 2 the first time it loads, but the third time when it goes back to 1 it changes in html but does not recover in data-status

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.