前台代码是这样的:
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")(result.data); } }) }
------解决方案--------------------------------------------------------
试试这样
- JScript code
var categoryId = $(this).attr("title");$.post("GetDocumentByCategoryId",{CategoryId:categoryId},function(data){ alert(datas);});