我有两个AJAX形式:Ajax.BeginForm总是excecuting一个“POST”
@using (Ajax.BeginForm("Index2","Home",
new AjaxOptions
{
UpdateTargetId = "result",
HttpMethod = "PUT"
},
new
{
onclick = "Sys.Mvc.AsyncForm.handleClick(this, new Sys.UI.DomEvent(event));",
onsubmit="Sys.Mvc.AsyncForm.handleSubmit(this, new Sys.UI.DomEvent(event), { insertionMode: Sys.Mvc.InsertionMode.replace, httpMethod: 'PUT', updateTargetId: 'result' });"
}))
{
<input type="hidden" name="id" value='1'/>
<input type="submit" value="OK Put" />
}
@using (Ajax.BeginForm("Index2","Home",
new AjaxOptions
{
UpdateTargetId = "result",
HttpMethod = "DELETE"
},
new
{
onclick = "Sys.Mvc.AsyncForm.handleClick(this, new Sys.UI.DomEvent(event));",
onsubmit="Sys.Mvc.AsyncForm.handleSubmit(this, new Sys.UI.DomEvent(event), { insertionMode: Sys.Mvc.InsertionMode.replace, httpMethod: 'DELETE', updateTargetId: 'result' });"
}))
{
<input type="hidden" name="id" value='1'/>
<input type="submit" value="Error Delete" />
}
在第一个,我excecuting一个PUT
,第二个一DELETE
,但在提琴手送花儿给人说,是POST
。
要继续测试,我添加了一个代码(这个代码仅与测试的建议)
(function() {
var origOpen = XMLHttpRequest.prototype.open;
XMLHttpRequest.prototype.open = function (a) {
console.log("~>" + a);
//console.log(this);
var x = a;
this.addEventListener('load', function() {
//console.log(this);
if(x == "POST"){
alert("Was a POST");
}
});
origOpen.apply(this, arguments);
};
})();
为什么我的其他HttpVerbs总是被excecuted为POST
?
@PatrickHofman基本上,这是不同的,因为这个问题它是基于线程的解决方案,并与'MVC'符号相关型号,问题不是以'jquery'的,它与'Razor' – MrMins 2015-02-24 14:35:41