使用以下脚本:
$(document).ready(function () {
$('#submit').click(function () {
var companyId = $('#companyCoid').val();
var erpKey = $('#erpKey').val();
if (companyId == "" || erpKey == "") {
alert("You have not entered enough information");
} else {
$.ajax({
type:post,
url: '@Url.Action("ErpDocument")',
data: {
coid: companyId,
documentKey: erpKey
}
});
}
});
});
我正在尝试触发此操作结果,该结果将导航到新视图:
[HttpPost]
public ActionResult ErpDocument(string coid, string documentKey)
{
var cview = new ConnectorViewModel();
Stuff and things here....
return View(cview);
}
我从上面的表单中获取信息,并且检查空白字段的工作正常,但是,我的控制器中的功能永远不会被命中。
编辑:我没有点击ActionResult的原因是我有post
而不是"POST"
,这现在命中了我的方法,但没有显示我的新视图。< / p>
答案 0 :(得分:0)
我认为默认的contenttype是xml。你可能需要添加这个
contenttype: "application/json; charset=utf-8"
。我认为这是我以前必须做的。虽然不太可能,但您可能还需要添加数据类型。