Hi guys,
again i need your help. i'm done deploying my MVC web application. but i have another problem encounter. my ajax did not work. my ajax inside my javascript. please see below code.
<script type="text/javascript">
$(document).ready(function () {
$('#btnLogin').click(function () {
var tmplogin = { "tmpUName": "", "tmpPword": "" };
tmplogin.tmpUName = document.getElementById('txtUserID').value;
tmplogin.tmpPword = document.getElementById('txtUserPassword').value;
$.ajax({
url: '/Home/Verify',
data: JSON.stringify(tmplogin),
type: 'POST',
contentType: 'application/json;',
dataType: 'json',
success: function (result) {
if (result.Success != 0) {
window.location.href = "/AdminPage/Index"
}
else {
alert(result.ex);
};
}
});
});
});
</script>
and my controller is:
[HttpPost]
public JsonResult Verify(string tmpUName, string tmpPword)
{
try
{
return Json(new { Success = 0, ex = "Success" });
}
catch (Exception ex)
{
return Json(new { Success = 0, ex = ex.Message.ToString() });
}
}
as simple as that.. yet it won't return any message.
i would believe that problem is in ajax because when i try to put an alert message after
tmplogin.tmpUName = document.getElementById('txtUserID').value;
tmplogin.tmpPword = document.getElementById('txtUserPassword').value;
alert("alert");
the alert messge will pop-up.
any idea how to resolve this? is there any dll or files needed to add on my reference?
thanks in advance.
-naijeru-