javascript - jQuery returning undefined with transaction.executeSql() -


i trying populate html tag data web sql database jqm application. here code:

 $("#profile").on("pageinit", function () {     db.transaction(function (transaction) {         var sql = "create table if not exists profile " +             " (id integer not null primary key autoincrement, " +             "nickname varchar(100) not null," +             "tankvol varchar(100) not null," +             "watertype varchar(100) not null," +             "category varchar(100) not null)"         transaction.executesql(sql, undefined);          var sqlnickname = "select nickname profile";         transaction.executesql(sqlnickname, undefined, function (transaction, result) {             var ul = "<ul>";             if (result.rows.length) {                 (var = 0; < result.rows.length; i++) {                     var row = result.rows.item;                     var nickname = row.nickname;                     ul += "<li>" + nickname + "</li>";                     ul += "</ul>";                  }             }             var $profilenickname = $("#profile div:jqmdata(role=content)");             $profilenickname.html(ul);             var $nicknamecontent = $profilenickname.find("ul");             $nicknamecontent.listview();         }, error);     }); }); 

the table using have 1 record i'm not sure need iterate through table loop or not. believe problem int line:

transaction.executesql (sqlnickname, undefined, 

because table working correctly , html being created correctly in list item element getting string "undefined" instead of value in nickname column of table. appreciated!

first of all, closing ur ul tag inside loop. if there more 1 entry in resultset, you'll several closing tags 1 opening tag. place closing tag outside loop.

but error getting this:

var row = result.rows.item; 

change to:

var row = result.rows.item(i); 

so program knows row take resultset. single result necessary.


Comments

Popular posts from this blog

c++ - Function signature as a function template parameter -

algorithm - What are some ways to combine a number of (potentially incompatible) sorted sub-sets of a total set into a (partial) ordering of the total set? -

How to call a javascript function after the page loads with a chrome extension? -