3
I am trying to submit a form via POST to a WebService
but I’m having the following problem:
No 'Access-Control-Allow-Origin' header is present on the requested Resource. Origin 'null' is therefore not allowed access. The Response had HTTP status code 404.
I’ve already added CORS filters to the project with WebServices
.
This is my requisition:
$("#frmLogin").submit(function(e){
var postData = $(this).serializeArray();
var fUrl = $(this).attr("action");
$.ajax({
type: 'POST',
url: fUrl,
contentType: 'application/x-www-form-urlencoded',
xhrFields:{
withCredentials: false
},
crossDomain : true,
xhrFields: {
withCredentials: false
},
data: postData,
success: function(result){
alert('sucesso');
},
error: function(){
alert('erro');
}
});
});
Something’s missing from it?
Are you submitting to the same domain or another? in the second case you are sure the service accepts
POST
external s?– Sergio
the request is being made from a different domain. In the case of the service I configured this way: I added some settings to the web.xml file
– Jadson de O. Rosa
Namely: <filter> <filter-name>CORS</filter-name> <filter-class>com.thetransactioncompany.Cors.Corsfilter</filter-class> <init-param> <param-name>Cors.allowGenericHttpRequests</param-name> <param-value>true</param-value> </init-param> <init-param> <param-name>Cors.allowOrigin</param-name> <param-value>*</param-value>... etc
– Jadson de O. Rosa