gpt4 book ai didi

javascript - 将 webSQL 结果存储到 var 以供其他函数使用?

转载 作者:行者123 更新时间:2023-11-30 18:39:54 24 4
gpt4 key购买 nike

代码如下:

speeddial.storage.findGroupName = function(id) {
speeddial.storage.db.transaction(function(tx) {
tx.executeSql('SELECT * FROM groups WHERE id = ?', [id], function (tx,results){
alert(results.rows.item(0).title);
return FolderName;
},
null);
});
}
function foo(results.rows.item(0).title){...

我希望将警告框中的结果 - results.rows.item(0).title - 存储在一个变量中并在下一个函数中使用...我是新手,可能不能等语法正确。警告框给了我预期的结果:)

最佳答案

使用指定的函数名称代替警报引用:

speeddial.storage.findGroupName = function(id) {
speeddial.storage.db.transaction(function(tx) {
tx.executeSql('SELECT * FROM groups WHERE id = ?', [id], function (tx,results)
{
foo(results.rows.item(0).title);
return FolderName;
},
null);
});
}

function foo(myresult){
/*...*/
}

关于javascript - 将 webSQL 结果存储到 var 以供其他函数使用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7141655/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com