我正在尝试执行ajax调用并使用ajax调用的结果填充"Data"div,但是我收到错误消息:"/'应用程序中的服务器错误.无法找到资源.说明:HTTP 404 .请求的URL:/ Home/GetStuff"当我查看Firebug时,请求是对/ Home/GetStuff的GET,答案是404未找到.为什么我不按照我在ajax调用中的要求进行POST?怎么办POST?
我尝试使用$ .post并获得了相同的行为,虽然我没有检查jquery代码,但我认为$ .post是$ .ajax的包装器.
另外我想Ajax.ActionLink并能正常工作,但我想用jQuery的,而不是微软的AJAX JS库.
代码如下:
首页/ TestStuff.aspx
function aClick() {
$.ajax({
type: "POST",
url: $("#MeFwd").href,
data: ({ accesscode: 102, fname: "JOHN", page: 0 }),
dataType: "html",
success: renderData
});
};
function renderData(data) {
$("#Data").html(data.get_data());
}
<div id="Data">
</div>
<div id="link">
<a href="<%= Url.Action("GetStuff", "Home") %>" id="MeFwd" onclick="aClick"> Click Me!</a>
</div>
Run Code Online (Sandbox Code Playgroud)
HomeController.cs
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult GetStuff(int accessCode, string fName, int? page)
{
return "<table><tr><td>Hello World!</td></tr></table>";
}
Run Code Online (Sandbox Code Playgroud) 运行这段代码时:
object P01 {
@annotation.tailrec
final def lastRecursive[A] (ls:List[A]):A = {
def lr[A] (l:List[A]):A = l match {
case h :: Nil => h
case _ :: tail => lr(tail)
case _ => throw new NoSuchElementException
}
lr(ls)
}
}
P01.lastRecursive(List(1,2,3))
Run Code Online (Sandbox Code Playgroud)
,在 Scala 2.10.2 REPL 中,我收到以下错误:
scala> :9: 错误:@tailrec 注释的方法不包含递归调用
final def lastRecursive[A] (ls:List[A]):A = {
^
Run Code Online (Sandbox Code Playgroud)
请帮忙,我不明白我做错了什么。