각도의 공장에서 아약스의 게시물 요청을 사용하고 있습니다 ... 아약스 성공 함수를 제외한 모든 것이 잘 작동합니다 ... 성공 함수에서 볼 수 있습니다. 다른 페이지로 이동해야합니다. . (logout.html) ..하지만 아약스의 성공 기능은 문제가 어떤 도움 무엇 내가 잘 모릅니다 ,, 로그인 버튼을 두 번 클릭 한 후 두 번째 페이지에 저를 로그인하시기 바랍니다 각 공장에서아약스 성공 함수 두 번째 클릭에 대한보기 반환
내 아약스 호출
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);
}
}
}
무엇입니까 '컨트롤러가 나에게 두 번째 페이지의 view'를 제공? 매우 자세한 설명을 해주십시오. –
이 질문은 18 분 전에 요청한 [this one] (http://stackoverflow.com/questions/21872015/ajax-requests-success-function-works-on-second-click)과 어떻게 다른가요? – jfriend00
now rowan을 참조하십시오 –