0

The error message I get in my browser's console is :

"XMLHttpRequest cannot load http://104.131.67.45/medical/register. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access."

please help me. Below is the code I am using to post to a remote server

    $(document).ready(function(){
        $("#save").on("click", function(){
              $.ajax({
                url:"http://104.131.67.45/medical/register",
                type:"POST",
                dataType:"json",
                jsonp:"callback",
                async:true,
                data:{mydata},

                ContentType:"application/json",
                success: function(response){
                    alert('success');
                    //alert(JSON.stringify(response));
                },
                error: function(err){
                    alert('failed');
                    //alert(JSON.stringify(err));
                }

               //var obj  = jQuery.parseJSON( response );
                // Now the two will work
                //$.each(obj, function(key, value) {
                //alert(key + ' ' + value);
            });
        });
    });
Chandu
  • 1
  • 1
  • Basic security stuff. What is the url? It must match the current domain for security reasons, except if the service you call explicitely allows a different domain. You want to read [this kind of question/answer](http://stackoverflow.com/questions/10636611/how-does-access-control-allow-origin-header-work). – Jeremy Thille May 08 '15 at 09:37
  • for answer http://stackoverflow.com/questions/10640596/header-set-access-control-allow-origin-in-htaccess-doesnt-work – Chandu May 11 '15 at 12:49
  • you have to use CROS plugin on server side it may be php or java – Chandu Jan 29 '18 at 07:31

0 Answers0