Вопрос

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