Donot重定向到json代码而不重新编译代码

时间:2016-06-28 11:39:38

标签: jquery json asp.net-mvc

我正在尝试从jquery重定向json方法。它在调试器或放置警告框时工作正常但在没有调试器的情况下无法重定向 PLZ为此提出了解决方案 感谢

// jquery code

 function ValidateMeetingOwner() {
    $.ajaxSetup({ cache: false });      
    debugger;
    var flagValue;
    var value = $("#meetingowner").val();
    if ($("#meetingowner").val() != "") {
        $.ajax({

            dataType: "json",
            url: '/MeetingForm/ValidationMeetingOwner',
            data: { Id: value },
            traditional: true,
            success: function (result) {
                debugger;
                if (result.result1 == "False") {
                    debugger;
                    flagValue = result.flag;
                    alert(result.flag);
                    alert(result.result1);
                    alert("Pleas Enter valid user for Meeting Owner");
                    $("#meetingowner").val("");

                }

                else {
                    flagValue = "1";
                }
            }
        });
        if (flagValue == "0")
        {
            return false;
        }
    }
  }

//控制器代码

public JsonResult ValidationMeetingOwner(string Id)
    {
        string result1 = string.Empty;
        string flag = string.Empty;
        var IfExist = dbcontext.Users.Any(x => x.Name == Id || x.Id == Id || x.Email == Id);
        if (!IfExist)
        {
            result1 = "False";
            flag = "0";
        }
        else
        {
            result1 = "True";
            flag = "1";
        }

        return Json(new { result1, flag }, JsonRequestBehavior.AllowGet);
    }

0 个答案:

没有答案