Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
1 Răspunde
4851 Vizualizări

I'm trying to query a database from inside a function and, then, use the values I get. However, although the query is performed appropriately and the values are correct, I am not able to return them.

Does anyone know how to fix the code below? :|

function get_coordinates(coords_id){
                var def = new $.Deferred();
                new instance.web.Model("gps_base.coords")
                    .query(['latitude_aux','longitude_aux'])
                    .filter([["id", "=", coords_id]])
                    .first()
                    .then(function(result) {
                        if(!result || result.length === 0){
                            def.reject();
                            return;
                        }else{
                            //this works!
                            //alert(result['latitude_aux']); 
                            def.resolve(result);
                        }
                    });
                    
                //this is "just" Object...
                //alert(def);
                return def;
            }

Imagine profil
Abandonează
Cel mai bun răspuns

Try to change this:

var def = new $.Deferred();

return def;

to this:

var def = $.Deferred();

return def.promise();

Imagine profil
Abandonează
Autor

Thanks, but it did no good.

Related Posts Răspunsuri Vizualizări Activitate
2
iul. 22
12503
1
aug. 19
4448
0
feb. 17
2918
2
oct. 22
5762
0
iun. 22
2711