View Single Post
Old 11-30-2012, 07:23 PM   PM User | #10
rnd me
Senior Coder

 
rnd me's Avatar
 
Join Date: Jun 2007
Location: Urbana
Posts: 3,452
Thanks: 9
Thanked 466 Times in 450 Posts
rnd me is a jewel in the roughrnd me is a jewel in the roughrnd me is a jewel in the rough
Quote:
Originally Posted by Philip M View Post
I can't tell you that because I don't know anything about CORS. Ask rndme.
As I understand it the CORS standard works by adding new HTTP headers that allow servers to serve resources to permitted origin domains.
But Javascript still cannot access those resources due to the SOP.
it's pretty straight-forward.

run this in firebug or devtool right now from here:

Code:
// normal 'ajax' function circa 2007:
function aGet(turl, callback) {
	var XHRt =  new XMLHttpRequest();

	XHRt.onreadystatechange = function () {
               if (XHRt.readyState == 4 && XHRt.status == 200) {
                   callback(XHRt.responseText, XHRt);
                }
        };

	XHRt.open("GET", turl, true);
	XHRt.send("");
	return XHRt;
} //end aGet()


// example async call to 3rd party domain:
aGet( 
    "http://cdn.atlas.illinois.edu/css/?file=http://www.it.illinois.edu/styles/screen.css" , 
    function(data){
        alert( data.toUpperCase() );
    }
);
it just works, no big whoop. you should see uppercase CSS when it's run.
__________________
my site (updated 5/13)
STATS (2013/5) HTML5:90.2% MOB:14% IE7:0.5% IE8:8.8% IE9:11.4% IE10:6.5%

Last edited by rnd me; 11-30-2012 at 07:28 PM..
rnd me is offline   Reply With Quote
Users who have thanked rnd me for this post:
johnsmith153 (12-01-2012)