0

I have tried to read a json from remote server, then i got this error.

"Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource"

Then i read that i need to set the datatype to jsonp.

  dataType: 'jsonp',

The problem is the json that i am getting isn't in jsonp format, which is required by jsonp. If i don't use jsonp i get the above error message.

How can I resolve this?

J_P
  • 642
  • 1
  • 8
  • 23
lonestar
  • 377
  • 1
  • 7
  • 16

1 Answers1

0

You have to enable a CORS request on the server side as well.

Add this line to your code: response.addHeader("Access-Control-Allow-Origin", "*");

You can replace * with your site's url if you want to allow only for particular domain.

Bhavika
  • 540
  • 1
  • 7
  • 16