Я пытаюсь запросить базу данных, которая содержит информацию о "тикете", используя метод jQuery .ajax () ...
$.ajax({
type: 'GET',
url: 'Preview.ashx',
data: 'ticketID=' + ticketID,
success: function (data) {
// 'data' should be a row from the database, so it should be like an
// array that contains each column of the row
// do stuff with this data
}
});
... чтобы всеработает отлично.У меня проблемы с переменной data
.На стороне сервера я делаю ...
// get the ticket ID from the POST parameter
int ticketID = context.Request["ticketID"] != null ? Convert.ToInt32(context.Request["ticketID"]) : -1;
if (ticketID >= 0) {
// grab the data from the database, getInfo() will retrieve the row
// in the DB that corresponds to the ticket ID given, returning an
// ArrayList with all of the information
ArrayList theTicket = getInfo(context, ticketID);
// now, I need to somehow return this information so that I could deal with it
// in the 'success' callback function above
return;
} else {
// something went wrong with the 'newTicket' POST parameter
context.Response.ContentType = "text/plain";
context.Response.Write("Error with 'ticketID' POST parameter. \n");
return;
}
return;
Я отладил это достаточно, чтобы быть уверенным, что ArrayList содержит правильную информацию.Теперь мне просто нужно вернуть его.
Как бы я это сделал?Как бы я вернул данные в ArrayList?Можно ли структурировать ответ так, чтобы я мог сделать data.ID
, data.otherColumnName
и т. Д. ... в функции обратного вызова для доступа к различным полям?