我正在使用jQuery的asp.net mvc ...我做了一個json調用一個控制器方法,它爲我返回json對象[Object object]
。我不想說,而不是我想要得到的JSON字符串...任何建議...這是否是一個有效的getJSON()在jQuery中?
$(document).ready(function() {
$.getJSON('Materials/GetMaterials', null, function(data) {
alert(data);
});
});
我給alert(data.d);
,這是undefined
public JsonResult GetMaterials()
{
var materials = consRepository.FindAllMaterials().AsQueryable();
return Json(materials);
}
@Mattias好吧,我怎麼能遍歷JSON對象...考慮含'UserName'和'EmailId' ....我想重複這些對象與'data.Username'和'data.EmailId 10rows ' – 2010-05-04 06:49:06
@Mattias這可能嗎? – 2010-05-04 06:49:31
@Pandiya Chendur,當然這是可能的。你可以使用JavaScript中的for循環。 jQuery有一個遍歷集合的每個方法。 – 2010-05-04 06:53:05