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

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -