我有一个名为login的函数,当用户按下按钮时,将执行下面的代码。
所以我试着看看用户是否存在并且在JSON对象中获取他的数据但是这不起作用,我得到以下消息:
SyntaxError: Unexpected token s
at Object.parse (native)
网址就像我想要的那样。
$scope.login = function() {
var request = $http({
method : "GET",
url : "/REST/user" + "/" + $scope.email + "/" + "password" + "/" + $scope.password,
headers : {
'Content-Type' : "application/json"
}
});
request.success(function(response) {
location.href = "../views/test.html"
});
request.error(function(response) {
growl.addErrorMessage("doesn't work", {
ttl : 4000
});
});
}
按浏览器输出
{
"id": "9be1804a-e366-11e4-9d4b-82ea0d805d53",
"email": "test@gmx.com",
"facebook_id": null,
"firstname": "test",
"lastname": "blabla",
"password": null,
"gender": null,
"is_active": "0",
"birthday": null
}