看那Network tab in FireBug
或類似的JavaScript調試工具。在那裏你會看到AJAX請求,你所要做的就是擴展請求並查看響應。
這裏有一個例子,如何可能看起來像螢火蟲的樣本AJAX請求:

如果您單擊JSON
選項卡上,你會看到格式化爲一個JSON對象輸出在那裏你可以展開/摺疊屬性。
如果出於某種非常奇怪的原因,您不能在您的Web瀏覽器中使用JavaScript調試工具(我甚至不知道您是如何開發Web應用程序的,但是......)您可以使用JSON.stringify
方法建成現代瀏覽器:
var jqxhr = $.getJSON("<%= Url.Action("GetTrainingModulePoints" , "Home") %>", function (json) {
alert(JSON.stringify(json));
});
而且如果你沒有使用最新的瀏覽器不具備JSON.stringify
方法本身內置的你仍然可以參考json2.js腳本到您的網頁。
UPDATE:
OK,看來你的困惑來自於事實,你得到{"success":true}
而您期望從你的存儲過程中獲得的行。我知道這是因爲我回答了您的previous question
。
下面是你的控制器動作的樣子:
[HttpGet]
public JsonResult GetTrainingModulePoints()
{
var currentUser = ZincService.GetUserForId(CurrentUser.UserId);
ZincService.TrainingService.GetTrainingModulePoints(currentUser.UserId);
return Json(new { success = true }, JsonRequestBehavior.AllowGet);
}
正如你可以在這個控制器的動作看你總是返回success = true
。如果你想從你的存儲過程返回的結果,你可以這樣做:
[HttpGet]
public JsonResult GetTrainingModulePoints()
{
var currentUser = ZincService.GetUserForId(CurrentUser.UserId);
var modulePoints = ZincService.TrainingService.GetTrainingModulePoints(currentUser.UserId);
return Json(
new {
success = true,
modulePoints = modulePoints
},
JsonRequestBehavior.AllowGet
);
}
在這裏,我假設你TrainingService.GetTrainingModulePoints
方法實際上是將一些對象。如果情況並非如此,那麼您將不得不解釋這些方法正在做什麼以及您希望如何獲得輸出。
請參閱OP我添加了FireBug中的圖片 –
當你檢查我的答案中顯示的AJAX請求的響應時,你在'Net'選項卡中得到了什麼? –
我得到了{「success」:true} –