PHPackages                             simonbengtsson/ajaxbridge - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. simonbengtsson/ajaxbridge

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

simonbengtsson/ajaxbridge
=========================

Proxy to circumvent the cross origin policy

16PHP

Since Oct 1Pushed 8y ago1 watchersCompare

[ Source](https://github.com/someatoms/ajaxbridge)[ Packagist](https://packagist.org/packages/simonbengtsson/ajaxbridge)[ RSS](/packages/simonbengtsson-ajaxbridge/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

Ajax Bridge
-----------

[](#ajax-bridge)

The purpose of AjaxBridge is to act as a proxy to circumvent the cross origin policy. It enables any javascript to send any request to any server and get the complete response back, including cookie headers.

### Usage

[](#usage)

This example fetches the html of the twitter homepage. The only required option is url`.

```
var options = {
    url: 'https://twitter.com/',
    method: 'GET',
    headers: {
        'User-Agent': 'AjaxBridge',
        'Other-Header': 'Value'
    },
    content: ''
};

$.post('https://ajax-bridge.appspot.com', options, function (res) {
    console.log(res); // See example response below
});

{
  "protocol": "HTTP/1.1",
  "status": 200,
  "statusText": "OK",
  "headers": {
    "cache-control": "no-cache, no-store, must-revalidate, pre-check=0, post-check=0",
    "content-security-policy-report-only": "default-src https:; connect-src https:; font-src https",
    "content-type": "text/html;charset=utf-8",
    "date": "Fri, 17 Oct 2014 18:16:10 UTC",
    "expires": "Tue, 31 Mar 1981 05:00:00 GMT",
    "last-modified": "Fri, 17 Oct 2014 18:16:10 GMT",
    "ms": "S",
    "pragma": "no-cache",
    "server": "tsa_a",
    "set-cookie": "guest_id=v1%3A141356977060427045; Domain=.twitter.com; Path=/; Expires=Sun, 16-Oct-2016 18:16:10 UTC",
    "status": "200 OK",
    "strict-transport-security": "max-age=631138519",
    "x-connection-hash": "e43d6d1abaacfa287738a7a17f329665",
    "x-content-type-options": "nosniff",
    "x-frame-options": "SAMEORIGIN",
    "x-transaction": "a1413ba660e67325",
    "x-ua-compatible": "IE=edge,chrome=1",
    "x-xss-protection": "1; mode=block",
    "X-Google-Cache-Control": "remote-fetch",
    "Via": "HTTP/1.1 GWA"
  },
  "content": "\n
