2
$(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.

3
  • What is this part of your url .. =?USD Commented Oct 30, 2012 at 20:46
  • It's the search query ("is which amount of US Dollars") Commented Oct 30, 2012 at 20:47
  • 2
    It doesn't look like that api supports JSONP, or at least I couldn't guess at what the jsonp callback param was. Doesn't look like an api that was meant to be accessed by other applications outside the google network of sites. Commented Oct 30, 2012 at 20:49

2 Answers 2

5

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.

Sign up to request clarification or add additional context in comments.

Comments

1

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

Here is one of plenty related topic : Cross domain exception

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.