首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

mvc过去台发送ajax请求得到的数据显示未定义(undefined),哪位帮忙看看

2012-10-23 
mvc从前台发送ajax请求得到的数据显示未定义(undefined),哪位帮忙看看前台代码是这样的:var categoryId

mvc从前台发送ajax请求得到的数据显示未定义(undefined),哪位帮忙看看
前台代码是这样的:
 var categoryId = $(this).attr("title");
var datas = $.ajax({
type: "POST",
sysnc: true,
url: "GetDocumentByCategoryId",
data: "CategoryId=" + categoryId,
dataType: "json"
}).responseText;
alert(datas);
[size=16px][/size]

后台代码:
 public JsonResult GetDocumentByCategoryId(int categoryId)
  {
  List<Document> documents = DocumentService.GetDocumentByCategory(categoryId);
  return Json(documents);
  }
调试显示已经成功从数据库中取到数据了!
但是在前台调用时显示未定义,哪位帮我看看!!!

[解决办法]
首先你断点打了进入后台controller了吧.如果进了然后他也成功返回了你说的哪个前台对象是undefined, 
其次

HTML code
'HTML'        var AjaxRefresh = function () {            $.ajax({                url: "/Test/TestAjaxFresh",                dataType: "json",                type: "post",                success: function (result) {                    $("#firstDiv").html(result.data);                }            })        }
[解决办法]
试试这样
JScript code
var categoryId = $(this).attr("title");$.post("GetDocumentByCategoryId",{CategoryId:categoryId},function(data){  alert(datas);}); 

热点排行