我需要做一些工作:
[我在第4步和第5步非常混淆]。我只是下面给出的示例代码括号,请转发您的知识。我知道这是凝灰岩。谢谢
我的代码:
public ActionResult Action(parameters)
{
foreach (var seletedid in id)
{
// my code
}
if (1st condition )
{
return Json(new { success = false });
// 1st error message i use like this
// after that the preform goes to the end
}
try
{
foreach (some code)
{
// my code
if (2nd condtion (3 point))
{
// using this i perform the some action herer
}
}
}
catch (Exception ex)
{
return null;
}
return null;
}
答案 0 :(得分:0)
在第一个按钮上点击下面的呼叫功能:
function MyFunction() {
$.post('@Url.Action("Action", "Controller")', { pareter1: value1, pareter2: value2 }, function (json) {
if (json.Status) {
var confirm = confirm("would you like perform the id for same student?");
if (confirm) {
$.post('@Url.Action("SecondAction", "Controller")', { pareter3: value3, pareter4: value4 }, function (result) {
//check the condition and proceed here, if needed.
});
}
});
}
</script>
如果您正在使用:
Ajax.BeginForm("Action", "ControllerName", new AjaxOptions { OnSuccess = "SuccessNotification" })
然后做:
function SuccessNotification(json) {
if (json.Status) {
var confirm = confirm("would you like perform the id for same student?");
if (confirm) {
$.post('@Url.Action("SectionAction", "Controller")', { pareter3: value3, pareter4: value4 }, function (result) {
//check the condition and proceed here, if needed.
});
}
}
}
当从服务器端返回某些内容时,将调用SuccessNotification。在这里,您可以检查返回数据,并根据您的条件调用下一个方法。