开发者

jQuery on Google site

开发者 https://www.devze.com 2023-01-11 04:57 出处:网络
I\'m trying to get the response text of www.google.com/movies using jQuery. I have tried from $.load to $.get, $.ajax, etc...

I'm trying to get the response text of www.google.com/movies using jQuery.

I have tried from $.load to $.get, $.ajax, etc...

Anybody can tell me if this is possible?

Some of my failed attempts:

$(document).ajaxError(function () { 
  alert('ajax error');
}开发者_Python百科);

$(document).load("http://www.google.com/movies?near=joinville,Santa+Catarina,Brazil", null, function (responseText) {   
  alert("Response:\n" + responseText);
});

$.getJSON("http://www.google.com/movies?near=joinville,Santa+Catarina,Brazil&callback=?",
  function (responseText) {
    if (responseText)
      alert("Response:\n" + responseText);
    else
      alert("fail");
  }
);

$.get("http://www.google.com/movies?near=joinville,Santa+Catarina,Brazil",
  null,
  function (responseText) {
    if (responseText)
      alert("Response:\n" + responseText);
    else
      alert("you fail again");
  }
);

$.ajax({
  cache: false,
  url: "http://www.google.com/movies?near=joinville,Santa+Catarina,Brazil",
  dataType: 'html',
  success: function (responseText) {
    if (responseText)
      alert("Response:\n" + responseText);
    else
      alert("you fail again");
  }
});


Same old ban on cross-domain requests:
http://en.wikipedia.org/wiki/Same_origin_policy

The most common work-around is to do this query on server side. (I don't think Google has AJAX API for its movie service)

0

精彩评论

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