$(".submit").click(function (e) {
e.preventDefault();
$.ajax({
async: true,
crossDomain: true,
method: "post",
data: $("form[name=something]").serialize(),
url: "myUrl",
success: function (res) {
console.log(res);
},
error: function (res) {
console.log(res.status);
},
});
});
and my spring mvc controller like
@RestController
@CrossOrigin(origins = {"*"},
methods = {RequestMethod.GET, RequestMethod.POST,
RequestMethod.PUT, RequestMethod.DELETE})
public class AppController {
...
...
...
}
If is send (get) request it work properly but when i send (post) it got exception :
Access to XMLHttpRequest at (remote server)from origin (localhost)has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.