Sergey
Sergey

Reputation: 49728

Cross-domain POST Ajax request without using proxy

Is it even possible to perform a cross-domain POST Ajax request without using proxy? I'm willing to use any kind of library to do this.

P.S. Request response is in JSON format.

Upvotes: 1

Views: 562

Answers (2)

hvgotcodes
hvgotcodes

Reputation: 120178

There is no way to do it if you don't control the server. Server side proxy is your only option.

Good thing is server-side proxy is fairly easy to do. Just create an endpoint that accepts the details of the request you want to make (http method, url, params), and then use whatever URL mechanism your framework of choice has to hit the other domain.

Upvotes: 2

Ruan Mendes
Ruan Mendes

Reputation: 92274

The other possibility is to use JSONP, which uses a script tag instead of AJAX

However, that requires that the server already support it, since it needs to wrap the returned JSON

Upvotes: -1

Related Questions