比较奇怪的有关问题 关于AJax的
比较奇怪的问题 关于AJax的
ajax部分
ashx部分
前台返回的是后台list[0].StudentCommmentId的异常信息,但是我在程序加了list.conut>0 的判断 这是为什么呢 很奇怪。
ajax没有进success error 返回500 错误信息
索引超出范围。必须为非负值并小于集合大小。参数名: index
------解决方案--------------------
500属于服务器错误了
ajax部分
var url = "Edit/GetCommentInfo.ashx?termId=" + termId + "&studentId=" + studentId;
$.ajax({
type: "post",
url: url,
dataType: "text",
async : false,
success: function(obj) {
var openUrl = "Edit/Form.aspx?termId=" + termId + "&studentId=" + studentId;
var commentId = obj;
if(commentId > 0)
{
openUrl += "&id=" + commentId;
}
As.Window.openWindow(openUrl, "openComment", As.Window.defaultWidth(), As.Window.defaultHeight(), true);
},
error: function() {
}
});
ashx部分
public class GetCommentInfo : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
int commentId = 0;
context.Response.ContentType = "text/plain";
int termId = RequestAgency.GetQueryInt("termId");
int studentId = RequestAgency.GetQueryInt("studentId");
IList<StudentCommentInfo> lit = StudentCommmentService.GetCommentInfo(studentId, termId);
if (lit != null && lit.Count > 0)
{
commentId = lit[0].StudentCommmentId;
}
context.Response.Write(commentId);
}
public bool IsReusable
{
get
{
return false;
}
}
}
前台返回的是后台list[0].StudentCommmentId的异常信息,但是我在程序加了list.conut>0 的判断 这是为什么呢 很奇怪。
ajax没有进success error 返回500 错误信息
索引超出范围。必须为非负值并小于集合大小。参数名: index
------解决方案--------------------
500属于服务器错误了