While sending a post request from my tomcat web service i got an error as below: \" Response to preflight request doesn\'t pass access control check: No \'Access-Control
You say "I tried to enable the CORS filter and tried to send get request that working fine."
Do you mean that GET method works but POST not? If so you must allow it on your REST service/terminal and also these settings header("Access-Control-Allow-Origin", "*") header("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT")
Finally, if by any chance your AJAX still returns failed try
$.ajax({
type : "POST",
url : "http://localhost:8080/userManagement/rest/Traffic/users2",
contentType :"application/json; charSet=UTF-8",
data : d,
dataType : "json",
**xhrFields: {
withCredentials: true
},
crossDomain: true,**
beforeSend: function (xhr){
console.log('Before');
xhr.setRequestHeader('Authorization', make_base_auth(user, pass));
}'