我正在尝试为Firefox OS创建一个应用程序,它基本上需要使用IndexedDB存储一些数据.
当用户单击提交按钮时,将调用store()函数,这将导致创建用户提交的表单的名称和描述变量.
但是,我一直收到一条引用错误,说我的db对象没有定义.任何想法为什么会这样?
这是我目前的代码: -
function store () {
// create the transaction with 1st parameter is the list of stores and the second specifies
// a flag for the readwrite option
var transaction = db.transaction([ 'Apps' ], 'readwrite');
//Create the Object to be saved i.e. our App details
var value = {};
value.name = name;
value.desc = description;
// add the details to the store
var store = transaction.objectStore('Apps');
var request = store.add(value);
request.onsuccess = function (e) { …Run Code Online (Sandbox Code Playgroud)