2015-09-29 83 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