0

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!

user3253067
  • 113
  • 2
  • 11
  • Sounds like you are dealing with a CORS issue. See if this related post helps (http://stackoverflow.com/questions/19821753/jquery-xml-error-no-access-control-allow-origin-header-is-present-on-the-req) – xspydr Jan 30 '14 at 13:02
  • 1
    possible duplicate of [No Access-Control-Allow-Origin header is present on the requested resource](http://stackoverflow.com/questions/20881532/no-access-control-allow-origin-header-is-present-on-the-requested-resource) –  Jan 30 '14 at 13:04

0 Answers0