在这一刻我打电话给我的索引视图的两种方式之一。使用正常的http视图并将其序列化为JSON。为了测试它,我使用下面的代码,并且它工作。我想通过http调用来获取它。赞(类似http://localhost/article,json什么的。任何想法。如何模拟来自HTTP GET调用的JSON调用?
$.getJSON("/Article", function(json) {
$.each(json, function(i, article) {
alert(article.title);
});
});
此时调用索引/文章在被分化与以下IsAjaxRequest方法。但我真正的问题是,如果我能够得到各地.getJSON在JQuery的方法来测试下面的代码。
if (Request.IsAjaxRequest())
{
return Json(articles);
}
else
{
return View(articles);
}