コンテンツへスキップ
メニュー
この質問にフラグが付けられました
1 返信
4837 ビュー

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;
            }

アバター
破棄
最善の回答

Try to change this:

var def = new $.Deferred();

return def;

to this:

var def = $.Deferred();

return def.promise();

アバター
破棄
著作者

Thanks, but it did no good.

関連投稿 返信 ビュー 活動
2
7月 22
12489
1
8月 19
4441
0
2月 17
2910
2
10月 22
5751
0
6月 22
2702