I am working on a project that needs to send data from a javascript function to a java class. I have been trying all the suggested methods that i have found on the internet but for the life of me, i can't manage to make them work. The error that i get from Chrome looks like this
OPTIONS "local path o servlet" No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'localhost' is therefore not allowed access. XMLHttpRequest cannot load "local path o servlet". No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'localhost' is therefore not allowed access
Basically my code looks like this where json is the data that i have to send :
$.ajax
(
{
url:'local path to servlet here using',
data: json,
type:'post',
cache:false,
success:function(data){alert(data);},
error:function(){alert('error');}
}
);
Can someone please help me with this? I am new in all this stuff and i would really need a hand!