- function LoadTiposIva() {
- if (TiposIva.length == 0) {
- //ajax function for fetch data
- $.ajax({
- type: "GET",
- url: '/FacturasENet/GetTiposIva',
- success: function (data) {
- TiposIva = data;
- console.log("1", TiposIva)
-
- }
- })
- }
-
- }
- function resto() {
- renderTipoIva($('#TipoIvaId'));
- console.log("2", TiposIva);
- }
- $.when(
- LoadTiposIva()
- ).done(
- resto()
- )
and when executing it it shows console "2" first and then "1", when it had to be backwards
I thought that "done" does not start running until it ends "when".
What am I doing wrong?
Thanks.