我觉得我错过了一些小事,但却无法找到它。关于为什么这段代码给我一个Javascript TypeError并指向" SQLValuseBoltUp的任何想法?
//Build SQL VALUES list
for(var counterBoltUp1 = 0; counterBoltUp1 < data.Entry.Page[PageIndexBoltUp].Table.length; counterBoltUp1++){
SQLValuesBoltUp.push("('" + data.Entry.SubmissionId + "'");
for(var counterBoltUp2 = 0; counterBoltUp2 < data.Entry.Page[PageIndexBoltUp].Table[counterBoltUp1].Answers.length; counterBoltUp2++){
SQLValuesBoltUp.push("'" + data.Entry.Page[PageIndexBoltUp].Table[counterBoltUp1].Answers[counterBoltUp2].Value + (counterBoltUp2 < data.Entry.Page[PageIndexBoltUp].Table[counterBoltUp1].Answers.length - 1 ? "'" : "')" ) );
}
}
编辑:清除是的,变量SQLValuesBoltup在此之前被初始化:
var SQLValuesBoltUp = [];
var PageIndexBoltUp = 2;
此处的数据也是如此:
var data = JSON.parse(request.body);
使用以下手动编写的代码执行SQLValuesBoltUp.push时,它可以工作:
SQLValuesBoltUp.push("('" + data.Entry.SubmissionId + "'",
"'" + data.Entry.Page[2].Table[0].Answers[0].Value + "'",
"'" + data.Entry.Page[2].Table[0].Answers[1].Value + "'",
"'" + data.Entry.Page[2].Table[0].Answers[2].Value + "'",
"'" + data.Entry.Page[2].Table[0].Answers[3].Value + "'",
"'" + data.Entry.Page[2].Table[0].Answers[4].Value + "'",
"'" + data.Entry.Page[2].Table[0].Answers[5].Value + "'",
"'" + data.Entry.Page[2].Table[0].Answers[6].Value + "'",
"'" + data.Entry.Page[2].Table[0].Answers[7].Value + "'",
"'" + data.Entry.Page[2].Table[0].Answers[8].Value + "')");
至于错误,这就是我能够从我正在使用的界面中获取的所有细节,并且还没有找到一种方法来查找要分享的错误的更多细节。
进一步澄清。以下是完整的代码:
//Static variables
var SQLFieldNamesBoltUp = "";
var SQLValuesBoltUp = [];
var PageIndexBoltUp = 2;
googleDBBoltUp.request = new AP.MySQL.Request();
//Automaticaly builds SQLFieldNames list by querying tblSubsBoltUp
for (var counterBoltUp = 1; counterBoltUp < googleDB1.response.data.length; counterBoltUp++){
if(counterBoltUp != googleDB1.response.data.length - 1){
SQLFieldNamesBoltUp = SQLFieldNamesBoltUp + googleDB1.response.data[counterBoltUp].COLUMN_NAME + ", ";
}else{
SQLFieldNamesBoltUp = SQLFieldNamesBoltUp + googleDB1.response.data[counterBoltUp].COLUMN_NAME;
}
}
//Build SQL VALUES list
for(var counterBoltUp1 = 0; counterBoltUp1 < data.Entry.Page[PageIndexBoltUp].Table.length; counterBoltUp1++){
SQLValuesBoltUp.push("('" + data.Entry.SubmissionId + "'");
for(var counterBoltUp2 = 0; counterBoltUp2 < data.Entry.Page[PageIndexBoltUp].Table[counterBoltUp1].Answers.length; counterBoltUp2++){
SQLValuesBoltUp.push("'" + data.Entry.Page[PageIndexBoltUp].Table[counterBoltUp1].Answers[counterBoltUp2].Value + (counterBoltUp2 < data.Entry.Page[PageIndexBoltUp].Table[counterBoltUp1].Answers.length - 1 ? "'" : "')" ) );
}
}
/*
SQLValuesBoltUp.push("('" + data.Entry.SubmissionId + "'",
"'" + data.Entry.Page[2].Table[0].Answers[0].Value + "'",
"'" + data.Entry.Page[2].Table[0].Answers[1].Value + "'",
"'" + data.Entry.Page[2].Table[0].Answers[2].Value + "'",
"'" + data.Entry.Page[2].Table[0].Answers[3].Value + "'",
"'" + data.Entry.Page[2].Table[0].Answers[4].Value + "'",
"'" + data.Entry.Page[2].Table[0].Answers[5].Value + "'",
"'" + data.Entry.Page[2].Table[0].Answers[6].Value + "'",
"'" + data.Entry.Page[2].Table[0].Answers[7].Value + "'",
"'" + data.Entry.Page[2].Table[0].Answers[8].Value + "')");
*/
//}