많은 것을 시도했지만 응답이 없습니다. mydomin/token에서 토큰을 검색하려고하는데 응답이 잘됩니다. 나는 그것을 디버깅했지만 Ajax는 응답을 얻지 못하고있다. 내가 여기에이Ajax에서 응답이 없습니다.
<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>
을 사용하고 나의 서버 코드
[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);
}
내가 뭘 브라우저와 포스트 사람에 반응을 얻고 것은
{
txt: false
}
입니다 그러나 아약스는 어떤 반응을 제공하지 않습니다 데이터가 경고를 표시하지 않습니다. 심지어이 있는지 확인하기 위해 않았다하지만 경고가
success: function (data) {
alert("Hi");
}
내가 이것과 스택에 다른 링크를 따라하지만 나를 위해 일하지 않았다 표시되지 않습니다.
how to call controller action in ajax url
데이터 유형을 추가하십시오 : ajax 호출에 'json' –
'myFunction1' 함수는 어떻게 호출합니까? – Shyju