I'm facing the following code in a success block of an Ajax request:
$('#something').remove();
alert('something was removed');
When executed I expected it to finish removing 'something' and pop up an alert afterwards, but for some reason alert pops up and only after it's confirmed the element is removed.
Why does this happen? It's trivial code and I would like to avoid callbacks and such. What should I check?
It was tested on FF. Thanks for tips.
console.log
instead ofalert
? – evolutionxbox Sep 5 '17 at 8:10setTimeout
on your alert with a short delay, i think it's a bit weird but it'll may work as you wish, just an idea – Nolyurn Sep 5 '17 at 8:16setTimeout(fn, 0)
– Kos Sep 5 '17 at 8:19