웹 서버로 apache tomcat을 사용하고 있습니다. tomcat에 webservices를 배포했습니다. jquery ajax를 통해 로컬 파일 시스템에서 요청을 게시하면 응답으로 tomcat webservice에 403 오류가 표시됩니다.Ajax jquery 호출 NetworkError : 403 응답에서 금지 된 오류
만약 내가 같은 컨테이너에서 나는 webservice에서 유효한 응답을 받고 있어요.
다음 코드를 사용하고 있습니다.
function callservice()
{
jQuery.support.cors = true;
var mobNo = document.getElementById('mobileNo').value;
var acctNo = document.getElementById('accountNo').value;
//var id = document.getElementById('id').value;
var custNo = document.getElementById('customerId').value;
//var mobNo = document.getElementById('txt_name').value;
//alert("mobileNo" + mobNo+"accountNo" + acctNo+"customerId "+custNo);
var url = "http://localhost/mobile-services/rest/user/";
var dataVal = {};
dataVal["mobileNo"] = mobNo;
dataVal["accountNo"] = acctNo;
dataVal["customerId"] = custNo;
var forminput = JSON.stringify(dataVal);
$.ajax({
url: url,
type: "POST",
data:forminput,
processdata: true,
contentType: "application/json;",
beforeSend: function() { },
headers :
{
"Content-Type" : "application/json",
"Accept" : "application/json"
},
success: function (data)
{
if (data.authenticated==true)
{
window.location.replace("http://localhost:8080/mobile-services/selected_services.jsp?userId="+data.id);
}
},
error: function (XMLHttpRequest, textStatus, errorThrown)
{
try
{
alert(JSON.stringify(XMLHttpRequest) + "\n" + textStatus + "\n" + errorThrown);
}
catch (ex) { alert("Exception occured.. "); }
finally { }
}
});
}
제안 해주십시오. 당신이 403
을 받고 왜 웹 서버가 그것을 크로스 도메인 통신 그게 가정하고 있기 때문에
Tomcat on top of apache를 배포 했습니까? 아니면 독립형입니까? http : // localhost –
으로 URL을 지정 했으므로 아파치를 통해 Tomcat에 요청을 라우팅한다고 가정합니다. $ .ajax 요청에 "jsonp", jsonp : "callbackname"을 추가 할 수 있습니까? ? –
독립 실행 형 설치입니다. jsonp와 같은 데이터 유형을 사용해 보았습니다. 예외가 허용되지 않는 메소드가 나타납니다. –