I have two arrays called one and two. one contains string values and two int values.
I'm trying:
var messageObject = { 'One': one,
'Two': two};
var serializedJSON = JSON.stringify(messageObject);
var json = JSON.parse(serializedJSON);
alert(json.One);
I'm getting "Undefined", though the array is populated. They are receiving data from a database, like this:
db.transaction(function(transaction) {
transaction.executeSql('SELECT * FROM aluno', [], function(transaction, results) {
len = results.rows.length, i;
for (i = 0; i < results.rows.length; i++) {
one[i] = results.rows.item(i).fieldOne;
two[i] = results.rows.item(i).fieldTwo;
}
}, null);
});
See the code:
oneandtwobefore definingmessageObject?