开发者

(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 b开发者_如何学Cecause 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);
        }
    });


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);
        }
    });


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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜