I have tried many things but not getting response from this. I am trying to retrieve token from mydomin/token and it is responding well. I debugged that and its working fine but Ajax is not taking the response. I am using this
<script>
//working but not getting response
function myFunction1() {
$.ajax({
type: "GET",
url: "/Account/CheckLogin?Email=" + $("#username").val()
+ "&password=" + $("#password").val(),
success: function (data) {
alert(data);
}
}).done(function (data) {
alert(data);
}).fail(showError);
}
</script>
Here is my server code
[HttpGet]
public JsonResult CheckLogin(Account account)
{
Result obj = new Result();
if (!account.Equals( null))
{
System.Diagnostics.Debug.Write(account.Email);
System.Diagnostics.Debug.Write(account.Password);
var result = db.Users.Any(x => (x.Username.Equals(account.Email) || x.Email.Equals(account.Email)) && x.Password.Equals(account.Password));
if (result)
{
//return RedirectToAction("Index", "Home");
obj.txt = true;
return Json(obj,JsonRequestBehavior.AllowGet);
}
}
obj.txt = false;
return Json(obj, JsonRequestBehavior.AllowGet);
}
What i am getting response in browser and Post man is
{
txt: false
}
But ajax is not giving any response in data not showing alert. Even i did this to make sure but no alert not shown
success: function (data) {
alert("Hi");
}
I followed this and some other links on stack but didn't worked for me. how to call controller action in ajax url