私は多くのことを試みましたが、これから応答を得ていません。 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>
を使用しています私は、ブラウザでの応答を取得していますし、ポストマンが
{
txt: false
}
しかし、Ajaxはのいずれかの応答を与えていないとは何私のサーバーコード
[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);
}
ですデータがアラートを表示していません。でも、私が確認するためにこれをしなかったが、何の警告が
success: function (data) {
alert("Hi");
}
を示さないではない私は、スタック上にこれと他のいくつかのリンクをたどったが、私のために働いていませんでした。 how to call controller action in ajax url
データ型を追加:ajaxコールに「json」 –
「myFunction1」関数をどのように呼び出すのですか? – Shyju