kirca
kirca

Reputation: 23

jQuery JSON AJAX request fails

$(document).ready(function() {
    $.ajax({
        type: 'GET',
        url: "http://www.google.com/ig/calculator?hl=en&q=1GBP=?USD",
        dataType: "json"
    }).done(function() {
        alert("success");
    }).fail(function() {
        alert('fail');
    });
});​

I'm new to this so please can someone tell me why does this fail? In firebug I am getting '200 OK' for the request.

Upvotes: 2

Views: 544

Answers (2)

hvgotcodes
hvgotcodes

Reputation: 120168

You can't make an ajax request to www.google.com unless the script from which the ajax request originates is loaded from www.google.com. It's called the Same Origin Policy. Browsers won't do it.

Upvotes: 5

sdespont
sdespont

Reputation: 14025

You are facing to a "cross-domain" request exception.

Here is one of plenty related topic : Cross domain exception

Upvotes: 1

Related Questions