JQuery 3.x 对象不支持 属性 或方法 'success'

JQuery 3.x Object doesn't support property or method 'success'

我正在使用雅虎天气 API。它适用于 JQuery 1.x。问题在于 JQuery 3.x。我收到此错误:对象不支持 属性 或方法 'success'。我可以用什么代替 .success?

我根据文档尝试了 .done,但它没有显示任何数据。

https://api.jquery.com/deferred.done/

$(document).ready(function(){
  var city = "Erie, PA";
  var searchtext = "select * from weather.forecast where woeid in (select woeid from geo.places(1) where text='" + city + "') and u='f'"
  $.getJSON("https://query.yahooapis.com/v1/public/yql?q=" + searchtext + "&format=json").success(function(data){
      $('#weather-temp').html(data.query.results.channel.item.condition.temp + "°F");
      $("#weather-title").text(data.query.results.channel.title);
      $("#weather-text").text(data.query.results.channel.item.condition.text);
      $("#weather-speed").text("Wind: " + data.query.results.channel.wind.speed + " mph");
      $("#weather-sunset").text("Sunset: " + data.query.results.channel.astronomy.sunset);
      var iconUrl = 'https://s.yimg.com/zz/combo?a/i/us/we/52/'
      var weatherCode = data.query.results.channel.item.condition.code;
      $(".weather_icon").attr('src', iconUrl + weatherCode + '.gif');
  });
});

看这里:http://api.jquery.com/jQuery.ajax/

.done(function() {
  //do stuff
});

对于getJSON,成功回调可以作为第二个参数传入。

参考。 http://api.jquery.com/jQuery.getJSON/

$.getJSON("https://query.yahooapis.com/v1/public/yql?q=" + searchtext + "&format=json", function(data){
      $('#weather-temp').html(data.query.results.channel.item.condition.temp + "°F");
      $("#weather-title").text(data.query.results.channel.title);
      $("#weather-text").text(data.query.results.channel.item.condition.text);
      $("#weather-speed").text("Wind: " + data.query.results.channel.wind.speed + " mph");
      $("#weather-sunset").text("Sunset: " + data.query.results.channel.astronomy.sunset);
      var iconUrl = 'https://s.yimg.com/zz/combo?a/i/us/we/52/'
      var weatherCode = data.query.results.channel.item.condition.code;
      $(".weather_icon").attr('src', iconUrl + weatherCode + '.gif');
  });