Note that there are some explanatory texts on larger screens.

plurals
  1. POcould not open db , $ is not defined, Failed to load jquery
    primarykey
    data
    text
    <p>The error is that the db could not be opened and $ not defined, failed to load resources(j query).The code aims at receiving the input field values(date,cal) and storing them into the database using indexedDB </p> <pre><code> &lt;!DOCTYPE html&gt; &lt;html manifest="manifest.webapp" lang="en"&gt; &lt;head&gt; &lt;meta charset="utf-8"&gt; &lt;title&gt;Diab&lt;/title&gt; &lt;link rel="stylesheet" href="diab.css"&gt; &lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0/jquery.min.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="diab1.js"&gt;&lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;input type="date" id="date"&gt;Date&lt;/input&gt; &lt;input type="number" id="cal"&gt;Cal&lt;/input&gt; &lt;button id="add" &gt;Add&lt;/button&gt; &lt;/body&gt; &lt;/html&gt; (function() { var db; var openDb=function() { var request=indexedDB.open("diabetore"); request.onsuccess = function() { console.log("DB created succcessfully"); db = request.result; console.log("openDB done!!"); }; request.onerror=function(){ alert("could not open db"); }; request.onupgradeneeded = function() { console.log("openDB.onupgradeneeded function"); var store = db.createObjectStore("diab", {keyPath: "date"}); var dateIndex = store.createIndex("date", "date",{unique: true}); // Populate with initial data. store.put({date: "june 1 2013",cal:70}); store.put({date: "june 2 2013",cal:71}); store.put({date: "june 3 2013",cal:72}); store.put({date: "june 8 2013",cal:73}); }; }; function getObjectStore(store_name,mode) { var tx=db.transaction(store_name,mode); return tx.objectStore(store_name); } function addItems(date,cal) { console.log("addition to db started"); var obj={date:date,cal:cal}; var store=getObjectStore("diab",'readwrite'); var req; try { req=store.add(obj); }catch(e) { if(e.name=='DataCloneError') alert("This engine doesn't know how to clone"); throw(e); } req.onsuccess=function(evt) { console.log("****Insertion in DB successful!!****"); }; req.onerror=function(evt) { console.log("Could not insert into DB"); }; } function addEventListners() { console.log("addEventListeners called..."); $('#add').click(function(evt){ console.log("add..."); var date=$('#date').val(); var cal=$('#cal').val(); if(!date || !cal) { alert("required field missing.."); return; } addItems(date,cal); }); } openDb(); addEventListners(); })(); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload