Postgres SQL에 데이터를 덤프하는 Java Restfull Webservice를 사용하고 있습니다. perfectely.Function 작업 자바 WebService에 기능 내가XMLHttpRequest error 요청한 리소스에 'Access-Control-Allow-Origin'헤더가 없습니다.
var obj = { hname: $("#txtRuleName").val(), hdates: $("#txtRuleDates").val(), hremark: $("#txtRuleRemark").val(), isDelete: false, created_date: 'CURRENT_TIMESTAMP', updated_date: 'CURRENT_TIMESTAMP' };
$.ajax({
type: "POST",
contentType: "application/json",
dataType: "json",
xhrFields: {
withCredentials: true
},
url: "http://localhost:8015/PostGresTestDB/rest/db/insert",
data: JSON.stringify(obj),
success: function (data, textStatus, jqXHR) {
alert('Data Inserted successfully...');
},
error: function (jqXHR, textStatus, errorThrown) {
alert('generateReportFromMR:Error in processing!');
//alert(jqXHR);
}
});
Webservice를가 http://localhost:8015/PostGresTestDB/rest/db/insert 및 웹 페이지가 실행중인 톰캣 서버에서 실행 아래처럼 JQuery와 아약스에서이 기능에 액세스하려고 지금
@Path("/db")
public class DBOperaions {
@POST
@Path("/insert")
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public String InsertDBData(@PathParam("hname") String hname,
@PathParam("hdates") String hdates,
@PathParam("hremark") String hremark,
@PathParam("isDelete") boolean isDelete,
@PathParam("created_date") String created_date,
@PathParam("updated_date") String updated_date) {
//Data Dumping Code
}
}
아래처럼 on
http://localhost:42229/index.html
다음 오류가 발생합니다.
XMLHttpRequest는 http://localhost:8015/PostGresTestDB/rest/db/insert을로드 할 수 없습니다. 'Access-Control-Allow-Origin'헤더가 요청 된 리소스에 없습니다. 따라서 원점 'http://localhost:49927'은 액세스 할 수 없습니다.
CORS를 시도했지만 성공하지 못했습니다.
아무에게도 내가 할 수있는 일이 정확히 무엇인지 말해 줄 수 있습니까?
Info @ Justine.Its는 잘 작동하지만 다른 문제는 내 다른 질문을 설명합니다. http://stackoverflow.com/questions/28336480/calling-parametrized-function-from-jquery-ajax -process-parameters-value-as-null – Jankya