将sqlite响应值传递给phonegap中的jquery函数

时间:2015-02-23 13:29:40

标签: javascript android jquery sqlite cordova

我正在开发一个phonegap应用。我在传递从sqlite DB到jquery函数的值时遇到了一些问题。 我将一个简单的日期变量传递给onclick = popUP("+date+");,但在接收端我获得了一些不同的值。例如,如果日期包含2015-02-24,则popUP正在接收1989。这是我的代码:

//function will be called when process succeed
function resultSuccess(tx,response) {

    for(var i=0;i<response.rows.length;i++){ 
         date = response.rows.item(i).ARTI_DATE;

        //alert("Title is : " +response.rows.item(i).ARTI_TITLE +"Date is : "+response.rows.item(i).ARTI_DATE+ "Des is : "+response.rows.item(i).ARTI_DESCRIP);

    var margin = 10;            
    $("#routeContainer").append("<div style = 'margin-left: " + margin + "px;'   class = 'test' id='d"+i+"' onclick='popUp("+date+")'><p style='padding-top: 90px;'><b>Thought for the..</b> <br/>Date: <span id='t"+i+"'>"+date+"</span> </p></div> ");
        $('.test').css('background', 'url(img/thumbs/thought.jpg) no-repeat').height(100).width(100);                   
        //$('.test').append($('<input></input>').attr('id','d'+i).attr('type','hidden').attr('value',date));
    }

}

function popUp(d) { 
      alert("Value is " +d);
      var db = window.openDatabase("DEVICEDATA", "1.0", "Device data", 200000); //will create database DEVICEDATA  
        db.transaction(SelectDesc, resultError, resultSuccess);
}

0 个答案:

没有答案