JD. JD. - 1 year ago 89
HTML Question

Why does ajax request with www work?

I have the following code:

url: frametarget,
dataType: 'html',
method: 'GET',
success: function(data){
// $("#result").html(data[0].title);
error: function(error){

Now if frametarget = "www.skysports.com" the call is a success but using skysports.com the call fails?

I am making cross domain calls for both URLs, so I expected both to fail.

Answer Source

For http://www.skysports.com cross domain requests are allowed by this response header: Access-Control-Allow-Origin: *.

For http://skysports.com there is no CORS header in the response, therefore the browser denies the request.

See MDN HTTP access control (CORS) for more informations.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download