用ajax获取后台数据,为什么不进入sucess?进入了error为什么结果是unddfined??? 代码如下:
$.ajax({url:"Service1.svc/DoWork",data:'{"Id":"dealGoalAction.listAll"}',type:"post",...
$.ajax({
url: "Service1.svc/DoWork",
data: '{"Id":"dealGoalAction.listAll"}',
type: "post",
dataType: "json",
contentType: "application/json;",
success: function (data) {
alert(data.d);
if (data.d) {
var obj = eval("(" + data.d + ")");
for (var i = 0; i < obj.TGoal.length; i++) {
$("#dtList").append("<tr><td><a href ='GoalDele.aspx?ID=" + obj.TGoal[i].id + "'>删除</a><a href ='GoalUpdate.aspx?ID=" + obj.TGoal[i].id + "'>编辑</a><a href='SubgoalAdd.aspx?ID=" + obj.TGoal[i].id + "'>添加子目标</a></td><td>" + obj.TGoal[i].id + "</td><td>" + obj.TGoal[i].name + "</td><td>" + obj.TGoal[i].Content + "</td><td><a href='AttForGoal.aspx?ID=" + obj.TGoal[i].id + "'>点击查看</a></td><td><a href='QuesForGoal.aspx?ID=" + obj.TGoal[i].id + "'点击查看</a></td></tr>");
}
}
},
error : function(data){
alert(data.d);
}
}); 展开
url: "Service1.svc/DoWork",
data: '{"Id":"dealGoalAction.listAll"}',
type: "post",
dataType: "json",
contentType: "application/json;",
success: function (data) {
alert(data.d);
if (data.d) {
var obj = eval("(" + data.d + ")");
for (var i = 0; i < obj.TGoal.length; i++) {
$("#dtList").append("<tr><td><a href ='GoalDele.aspx?ID=" + obj.TGoal[i].id + "'>删除</a><a href ='GoalUpdate.aspx?ID=" + obj.TGoal[i].id + "'>编辑</a><a href='SubgoalAdd.aspx?ID=" + obj.TGoal[i].id + "'>添加子目标</a></td><td>" + obj.TGoal[i].id + "</td><td>" + obj.TGoal[i].name + "</td><td>" + obj.TGoal[i].Content + "</td><td><a href='AttForGoal.aspx?ID=" + obj.TGoal[i].id + "'>点击查看</a></td><td><a href='QuesForGoal.aspx?ID=" + obj.TGoal[i].id + "'点击查看</a></td></tr>");
}
}
},
error : function(data){
alert(data.d);
}
}); 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询