Ajax.ActionLink是不张贴 [英] Ajax.ActionLink is not POSTing

查看:119
本文介绍了Ajax.ActionLink是不张贴的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过张贴,而不是让浏览到一个MVC动作。 (该操作是删除,我不希望它通过访问一个外部链接。)

I am trying to navigate to an MVC action by POSTing rather than GETting. (The action is a DELETE, and I don't want it reachable by an external link.)

我正在使用由

 Ajax.ActionLink("Remove", "Delete", new { saID = Model.Said, id = e.id }, new AjaxOptions { HttpMethod = "POST", Confirm = "Are you sure you want to delete this item?" })

产生下面的HTML:

Which generates the following HTML:

<a href="/Equipment/Delete/102424/229933" onclick="Sys.Mvc.AsyncHyperlink.handleClick(this, new Sys.UI.DomEvent(event), { insertionMode: Sys.Mvc.InsertionMode.replace, confirm: 'Are you sure you want to delete this item?', httpMethod: 'POST' });">Remove</a>

我的问题是,当我点击链接,我达到了通过GET而不是POST删除操作,确认对话框不会发生。我一直在谷歌上搜索这几个小时,不断得到缠轴。我究竟做错了什么?

My problem is that when I click on the link, I am reaching the Delete action via a GET rather than a POST, AND the Confirm dialog is not taking place. I have been googling this for several hours and just keep getting wrapped around the axle. What am I doing wrong?

推荐答案

这可能是因为你有一些其他的JavaScript错误页面是preventing处理的AJAX POST运行的JavaScript上。在这种情况下,链接回落到它的默认行为(GET)。最容易做的事情是使用IE8的开发人员工具或Firefox / Firebug的(我preFER这些),并看看是否有在控制台中的任何错误页面加载或您的行为被调用时。如果您使用的是IE浏览器,你需要使用 Internet选项 - &GT;高级并取消禁用脚本调试

It's likely that you have some other javascript error on your page that is preventing the javascript that handles the AJAX POST from running. In this case, the link falls back to it's default behavior (GET). The easiest thing to do is use the IE8 developer tools or Firefox/Firebug (I prefer these) and look to see if you have any errors in the console when the page loads or your action is invoked. If you are using IE you'll need to use Internet Options -> Advanced and uncheck Disable script debugging.

解决您的JavaScript错误,我认为这将只是开始工作。

Fix your javascript error and I think it will simply start working.

这篇关于Ajax.ActionLink是不张贴的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆