This question already has answers here:
</div>
</div>
<div class="grid--cell mb0 mt4">
<a href="/questions/14220321/how-do-i-return-the-response-from-an-asynchronous-call" dir="ltr">How do I return the response from an asynchronous call?</a>
<span class="question-originals-answer-count">
(38 answers)
</span>
</div>
<div class="grid--cell mb0 mt8">Closed <span title="2016-06-28 18:55:12Z" class="relativetime">3 years ago</span>.</div>
</div>
</aside>
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!
</div>