私は角度の工場で ajax の投稿要求を使用しています.... ajax 成功関数を除いてすべて正常に動作します...成功関数で見ることができます。別のページに移動する必要があります..(logout.html)..しかし、ajax の成功関数ログインボタンを 2 回クリックした後、2 番目のページにログインします。何が問題なのかわからないので、助けてください
angular factoryでの私のajax呼び出し
demoapp.factory("authser", function ($location) {
return {
login: function (credantials) {
if (credantials.username != "jot") {
alert("its ");
}
else {
$.ajax({
url: "/valued/newvalue",
type: 'POST',
data: { 'name': credantials.username, 'password': credantials.password },
dataType: "json",
success: function (data) {
console.log(data);
$location.path('/logout');
}
});
}
},
logout: function (data) {
console.log(data);
$location.path('/hello');
}
}
})
私のコントローラー
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace angulardata.Controllers
{
public class valuedController : Controller
{
// GET: /valued/
[HttpPost]
public ActionResult newvalue(string name, string password)
{
var res = new {Success="True",Message="Error MEssage" };
return Json(res);
}
}
}