Tom Gullen
Tom Gullen

Reputation: 61729

(simple) Jquery ajax not returning data

The alert box will display nothing, and not return any data from any URL when it should be showing the google page! Any ideas? I'm using POST because I'm trying to get it to send querystring data as well.

    $.ajax({
        type: "POST",
        url: "http://www.google.com",
        success: function(msg) {
            alert("Data Saved: " + msg);
        }
    });

Upvotes: 1

Views: 796

Answers (3)

dzida
dzida

Reputation: 8981

You can do this only if you own google.com which I believe is at least unlikely:) (cross domain issues)

To overcome this you can make post to your server and let server connect to google.com, then you can respond to the user with data retrieved from google.com.

Upvotes: 0

Muneer
Muneer

Reputation: 7564

yea TOm,

You are doing cross-domain scripting.

change the URL to a file which is in your own Domain.

$.ajax({
        type: "POST",
        url: "anyfileinYourDomain.xxx",
        success: function(msg) {
            alert("Data Saved: " + msg);
        }
    });

Upvotes: 3

spinon
spinon

Reputation: 10847

I would try setting the dataType to html and see if that helps.

Upvotes: -2

Related Questions