function getReportGroups() {
$.ajax({
contentType: "application/json; charset=utf-8",
url: "ReportGroups.ashx",
data: {
'method': 'getReportGroups',
'projectId': '30390'
},
dataType: "json",
success: function (data) {
alert('inside success');
var i = 0;
groupName = [data[i].name];
while (data[i] != null) {
alert([data[i].name]);
alert([data[i].reportGroupId]);
$("#top-node").append("<li item-checked='true' item-expanded='true'><a href=# style=font-weight:bold>" + [data[i].name] + "</a>");
i++;
var id = [data[i].reportGroupId];
getReports(id);
}
},
error: function (result) {
alert("Error- Inside the error loop");
}
});
}
function getReports(id) {
$.ajax({
contentType: "application/json; charset=utf-8",
url: "ReportGroups.ashx",
data: {
'method': 'getReports',
'reportGroupId': id
},
dataType: "json",
success: function (data) {
alert('inside getReports success');
var i = 0;
groupName = [data[i].name];
while (data[i] != null) {
alert([data[i].name]);
i++;
}
},
error: function (result) {
alert("Error- Inside the error loop");
}
});
}
これは私のコードです。ここで、パラメータ id を使用して getReportGroups() から getReports(id) を呼び出すと、getReoprts() 関数で id がゼロとして渡されます。何が問題なのかわからない。アラート ボックスを使用して、最初の ID に「ID」が存在するかどうかを確認しました。getReportsFunction に有効な ID があります。しかし、私は2番目にIDをゼロとして取得しています。ここで何が間違っていますか?