jquery+ajax很重要的一个问题,在线等待!
各位大侠帮我看一下以下代码:
这是前台JS代码
$.post("MoviesInfo.ashx", function (list) {
var comments = $.parseJSON(list);
var li = $("<li id='movie'>" + comments[0].name + "</li>");
$("#movie").append(li);
});
以下是后台代码:
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
var data = new movieinfoTableAdapter().GetMovieName();
if (data.Count == 0)
{
return ;
}
List<Movie> list = new List<Movie>();
foreach (var row in data)
{
list.Add(new Movie() {
ID = row.MovieID,
name=row.MovieName,
director=row.MovieDirector,
actor=row.MovieActor,
intro=row.MovieIntroduction,
link=row.DownLaodlink,
image=row.MovieImage,
hit=row.hit,
subjectid=row.SubjectID
});
}
JavaScriptSerializer jss = new JavaScriptSerializer();
context.Response.Write(jss.Serialize(list));
}
public class Movie
{
public int ID { get; set; }
public string name { get; set; }
public string director { get; set; }
public string actor {get;set;}
public string intro { get; set; }
public string link { get; set; }
public string image { get; set; }
public int hit { get; set; }
public int subjectid { get; set; }
}
不知道到底是什么情况,js发送请求以后不能进入后台。请各位大侠帮帮忙忙吧! 在线等待高手出现!
(js是用于初始化页面的)
------解决方案--------------------
你看看路径是不是正确的,就是你的MoviesInfo.ashx所在的文件夹,是根目录吗,还是在哪里,如果是某个文件夹,你就用"../文件夹名称/MoviesInfo.ashx"这样的试试