This question already has an answer here:
I have this function:
function getNamep(id_user) {
$.post('php/back.php', {
id: id_user,
f: "getName"
}, function (data) {
data = jQuery.parseJSON(data);
if (data[0] == 1) {
console.log(data)
}
else {
console.log(data)
}
});
}
I want to get the result here:
var name = getNamep(2);
How i can do this? Returning data from $.post()
Thanks!
Aucun commentaire:
Enregistrer un commentaire