2015-09-29 84 views
-2

我jQuery的功能看起來以下,商店返回值

var d= rdldb.restaurantbooking.where('date').equals("2015-09-30").toArray(jstr); 
//jstr is a function 

function jstr(v){ return JSON.stringify(v); } 

//console.log(JSON.stringify) shows my desired output 
//and the same output need to be shown when i display variable d. 

/* output of jstr() function is 
    [{"booking_id":-2,"restbooking_id":"RDOFFL-2",,"bstate":"on"}  
    ,{"booking_id":"18487","restbooking_id":"RDOFFL-3","bstate":"on"}, 
    {"booking_id":"18488","restbooking_id":"Id9","bstate":"on"}, 
    {"booking_id":"18489","restbooking_id":"d","bstate":"on"}] 
*/ 

console.log(d); //Output is empty . 

jstr()功能沒有返回值變量d。

在第一個函數中獲得所需輸出的解決方案是什麼?

+0

僅供參考這裏沒有jQuery代碼。其次,where(),equals()和toArray()是什麼輸出? –

+0

某些瀏覽器不會在控制檯中顯示對象,除非調試器也處於打開狀態,請嘗試在Firefox中使用F12,而不是僅使用瀏覽器控制檯 – Icepickle

+0

@RoryMcCrossan。這是jQuery中實現的indexedDB函數 – Arockiaraj

回答

0

數組「x」將包含JSON數組的字符串化版本d。

var d = rdldb.restaurantbooking.where('date').equals("2015-09-30").toArray(); 

var x = new Array(); 

for (var i=0; i < d.length; i++) { 
    x.push(JSON.stringify(d[i])); 
} 
+0

toArray()應該有一個回調函數,就像我的問題中給出的那樣。所以從回調值應該返回到d。 – Arockiaraj