按钮单击我调用了一个js函数,这个js函数称为操作方法。但如果json结果是0(不是错误),我想重定向到部分视图。 JS功能:在控制器从ajax返回部分视图调用
function AssignButtonClicked(step, parent, show) {
alert("coming: " + step + " parent: " + parent + " show is : " + show);
$.ajax({
type: "POST",
url: "/Jobs/PassInstructionTest",
data: "{stepGuid: '" + step + "', parentGuid: '" + parent + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (response) {
alert("resp is : " + response);
if (response == '0') {
alert('qa called!');
$("#forqa").show();
}
if (response == '1') {
}
},
error: function (response) {
alert(response.responseText + " error for fail");
},
});
return false;
}
动作方法:
public ActionResult PassInstructionTest(Guid stepGuid, Guid parentGuid, string show)
{
bool isQA = false;
if (!isQA)
{
return Json(0, JsonRequestBehavior.AllowGet);
}
else
{
return PartialView("MyPartialView");
}
}
MyPartialView
当被调用时,它被投掷误差作为执行错误子请求。
请为我提供解决方案。
当你的'isQA'成立时? – SeM
为了测试我传递它为false。如果QA为真,那么我想打开一个Modal弹出窗口,否则执行返回的部分视图。部分视图正在调用,但它不重定向它,并抛出错误作为执行子请求的错误。我是否需要更改JavaScript功能? –
而这个click事件也存在于局部视图.. –