I have been facing an issue to display "Message Box" after executing of some code in controller
for ex:-
public ActionResult IsLoginExsit(CustomerDO loginData)
{
JsonResult jsonResult = new JsonResult();
if (!string.IsNullOrEmpty(loginData.UserName) && !string.IsNullOrEmpty(loginData.Password))
{
bool result = Businesss.Factory.BusinessFactory.GetRegistrations().IsLoginExist(loginData.UserName, loginData.Password);
jsonResult.Data = result;
}
return jsonResult;
}
as seen in above example, if result is true or false, then i would like to display message box stating that login is suceess or fail.
<!-- language: lang-.html -->
<form class="formStyle" action="#" method="POST" id="frmAuthenticate">
<div class="row">
<input class="text row" type="text" value="" id="txtUserName"/>
</div>
<div class="row">
<input class="text row" type="password" value="" id="txtPassword" />
</div>
<div class="row last">
<a class="link" href="">Forgot Password?</a>
<a class="button3" href="/Registration/Registration" title="Registration" >Signup</a>
<input type="submit" class="button4" id="btnGo" value="Go" />
</div>
</form>
If login is exist i want to navigate to "/Customer/CollaborationPortal", else i would like to display message "Authroization fail".
$("#btnGo").click(function (e) {
var RegData = getRegData();
if (RegData === null) {
console.log("Specify Data!");
return;
}
var json = JSON.stringify(RegData)
$.ajax({
url: '/Registration/IsLoginExsit',
type: 'POST',
dataType: 'json',
data: json,
contentType: 'application/json; charset=utf-8',
success: function (data) {
if(data.result == true){
location.href = "/Customer/CollaborationPortal";
}
else{
alert("Login failed"); //or whatever
}
}
});
return false;
});
function getRegData() {
var UserName = $("#txtUserName").val();
var Password = $("#txtPassword").val();
return { "UserName": UserName, "Password": Password };
}
Thanks in advance