Hello,

I'm working with Tomcat 9.0.6 version as my servlet,
I have tested my web service with postman and it seems to work fine.

While i tried to send simple ajax that i have build and tested in chrome, i
got an error.

*the request is :*

function setAllTlcsStatus() {
var tlc = [{"id":1, "code":2, "time":"2009-02-15", "cycleSecond":22,
"programNumber":1221, "stageNumber":22, "moves":"22",
"detectors":"fead","conditions":"2ddsa"};
data.push(tlc);
$.ajax({
type: 'POST',
url: "http://127.0.0.1:8080/userManagement/rest/Traffic/users2";,
dataType: 'json',
contentType: 'application/json',
data: JSON.stringify(tlc),
                success: function( data, textStatus, jQxhr ){
                    alert("good");
                },
                error: function( jqXhr, textStatus, errorThrown ){
                    alert("Not good");
console.log( errorThrown );
                }
});
}


*and the error i got:  *

*Failed to load http://127.0.0.1:8080/userManagement/rest/Traffic/users2
<http://127.0.0.1:8080/userManagement/rest/Traffic/users2>: Response to
preflight request doesn't pass access control check: No
'Access-Control-Allow-Origin' header is present on the requested resource.
Origin 'null' is therefore not allowed access.*

Reply via email to