PHP Advent 2011: Cross-Origin Ajax with CORS

By  on  
Cross-Origin Ajax with CORS

I've had the honor of writing for this year's PHP Advent, blessing you all about Cross-Origin Requests with CORS:

There's no doubt that Ajax is one of the most exciting, useful, and necessary web technologies available to front-end developers. Unfortunately, it's also one of the most restrictive — especially when it comes to gathering content from other domains. Web developers are nothing if not persistent, so we've come up with a variety of ways to get around cross-origin restrictions, including JSONP, server-side proxies made with PHP, ProxyPass proxying, Flash transports, creative iFrame uses, and more. What many developers don't know is that there's a W3C specification called Cross-Origin Resource Sharing, or CORS, which provides a standard for cross-origin Ajax requests with minimal hassle.

That's my Christmas gift to you all!

Recent Features

Incredible Demos

  • By
    CSS Sprites

    The idea of CSS sprites is pretty genius. For those of you who don't know the idea of a sprite, a sprite is basically multiple graphics compiled into one image. The advantages of using sprites are: Fewer images for the browser to download, which means...

  • By
    Pure CSS Slide Up and Slide Down

    If I can avoid using JavaScript for element animations, I'm incredibly happy and driven to do so.  They're more efficient, don't require a JavaScript framework to manage steps, and they're more elegant.  One effect that is difficult to nail down with pure CSS is sliding up...

Discussion

  1. Eric

    The link to your post isn’t working ;) Nice article BTW, but 10 seconds too late! I just figured out that this should solve my problem with the help of our friend Google :( Nice to read that this is the way things will work for sure.

  2. Alex

    Hi David, can this this hide the httprequest referrer??

Wrap your code in <pre class="{language}"></pre> tags, link to a GitHub gist, JSFiddle fiddle, or CodePen pen to embed!