:만들기 AJAX 호출 내가 아약스와의 API 호출을 만들려고 노력하고
svc.authenticateAdmin = function (id, code) {
$.ajax({
url: 'api/event/authenticate',
data: { 'id': id, 'code': code },
datatype: 'json',
contentType: 'application/json',
type: 'GET',
success: function (data) {
App.eventBus.publish('authenticationComplete', data);
}
});
};
API를 컨트롤러에있어서
[ActionName("All")]
public bool Authenticate(int id, string code)
{
var repo = new MongoRepository<Event>(_connectionString);
var entry = repo.FirstOrDefault(e => e.Id == id);
return entry.AdminPassword == code;
}
하지만 404 오류가 점점 오전 : urlstuff/api/event/authenticate? id = 123 & 코드 = abc 404 (찾을 수 없음)
나는 (내가 쓰지 않은) 많은 알려진 작업 호출로부터 구현을 복사했습니다.
svc.getEventFromCode = function (code) {
$.ajax({
url: '/api/event/',
data: { 'code': code },
dataType: 'json',
type: 'GET',
success: function (data) {
App.eventBus.publish('loadedEvent', data);
App.eventBus.publish('errorEventCodeExists');
},
error: function() {
App.eventBus.publish('eventNotFound', code);
}
});
};
및
svc.getEventPage = function (pageNumber) {
$.ajax({
url: '/api/event/page/',
data: { 'pageNumber': pageNumber },
dataType: "json",
contentType: "application/json",
type: 'GET',
success: function (data) {
App.eventBus.publish('loadedNextEventsPage', data);
}
});
};
그러나 어느 쪽도 API에이 개 매개 변수를 전달합니다 :처럼 그것은 보인다. 나는 정말 작은 뭔가 같은데요 :/
브라우저를 통해'urlstuff/api/event/authenticate? id = 123 & code = abc 404'주소로 직접 접근 할 수 있습니까? – user1477388
예, 방문 페이지로 리디렉션됩니다. – jokulmorder