V.Rashkov
V.Rashkov

Reputation: 1735

Why request to site returns error Access-Control-Allow-Origin

Ok so, i'm making ajax request to site page, and it doesn't return anything - page is valid, but it gives this error in the console . Origin http://localhost is not allowed by Access-Control-Allow-Origin.

How to fix it, i wan't to connect to the page properly.

Upvotes: 0

Views: 145

Answers (1)

Sandeep
Sandeep

Reputation: 819

You are seeing this error because of browsers Same origin policy which prevents XML HTTP requests(AJAX) to be made to other domains and sub-domains. There are many workarounds of which JSONP is favoured among many developers. But, this requires the server/page to which you're making the request to serve JSONP response.

Upvotes: 1

Related Questions