Pick up value of a $.get()

Asked

Viewed 53 times

-1

I have a small jQuery function that checks which is the last registered ID in a database table.

However, I need to store the values in a variable and I realize that I can’t get the value generated by $.get, The most I can get is a [object Object].

This was an attempt by several;

var ultimoRegistro = $.get("./core/consulta-unidades.php", function(data){      
        return data;
    });
alert(ultimoRegistro);

1 answer

0


$.get() does not return the value of the callback function and the operation is asynchronous. Maybe it is a key inside the object.

$.get("./core/consulta-unidades.php", function(data){      
    console.log(data);
});

Browser other questions tagged

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