ho provato anche così:
quello che non capisco è che mi esce prima il console contrassegnato come 2, con valore undefined.codice:function getMediaId(id, async = true) { let out; $.ajax({ url: baseUrl + 'media/' + id, type: 'GET', aysnc: async, contentType: "application/json; charset=utf-8", dataType: "json", async: false }).done(function (res) { out = res.source_url; console.log("1:" + out); }).fail(function (err) { out = 'images/white.jpg'; }); console.log("2:" + out); return out; }
e poi quello con 1, col valore corretto.
in teoria, forzando l'async, questo non dovrebbe succedere!

Rispondi quotando
