質問

I am trying to work with the Google API for suggest queries. But I am getting an error.

Here is my code:

$.ajax({
  url:'http://suggestqueries.google.com/complete/search?client=chrome&q=sheikh+hasina',
  type:"GET",
  dataType: 'jsonp',
  jsonp:function (data) {
    console.log('yes');
  },
  async:'true',
  success:function (data) {
    console.log('yes');
  },
  error: function(jqXHR, textStatus, errorThrown){
    console.log(jqXHR);
    console.log(textStatus);
    console.log(errorThrown);
  }
});
役に立ちましたか?

解決

Assuming that you're trying to get JSONP data from a URL, try this instead.

$.ajax({
  url: 'http://suggestqueries.google.com/complete/search?client=chrome&q=sheikh+hasina',
  type: 'GET',
  dataType: 'jsonp',
  success: function (data) {
    console.log(data);
  },
  error: function(jqXHR, textStatus, errorThrown){
    console.log(jqXHR);
    console.log(textStatus);
    console.log(errorThrown);
  }
});
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top