0

I am using jQuery to fetch the cross domain data but I am getting this error

SyntaxError: missing ; before statement here is my code

<script>
     (function($) {
     var url = '//heald-chiampa.tributes.com/funeral_homes/search?json=1';
     $.ajax({
            type: 'GET',
        url: url,
        async: false,
        contentType: "application/json",
        dataType: 'json',
                success: function(json) {
       alert(json);
     },
     error: function(e) {
       console.log(e.message);
     }

     });
    })(jQuery);
</script>

when I change datatype from jsonp to json then i am getting this error Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://heald-chiampa.tributes.com/funeral_homes/search?json=1. (Reason: CORS header 'Access-Control-Allow-Origin' missing).

Rwd
  • 34,180
  • 6
  • 64
  • 78
Raman verma
  • 73
  • 1
  • 11

2 Answers2

0

he simple answer is you cannot access another domain service from jquery. Read about CORS here

Akki619
  • 2,386
  • 6
  • 26
  • 56
0

The server getting the request should output this header:

Access-Control-Allow-Origin: http://www.yourdomain.com
Evdv
  • 75
  • 1
  • 8