0

jQuery.getScript を使用して、Google マップを API キーで動的にロードしています。

jQuery.getScript("http://maps.googleapis.com/maps/api/js?sensor=false&key=APPKEY&callback=initMap", function(data, textStatus, jqxhr) {
   console.log(textStatus); //success
   console.log('Load was performed.');   
   console.log(jqxhr.status); //200
});


function initMap(){
var mapOptions = {          
center: new google.maps.LatLng(25.245178, 55.359438),           
zoom : 15,
mapTypeId : google.maps.MapTypeId.ROADMAP,
mapTypeControl : false   
};        
var map = new google.maps.Map(document.getElementById("map_canvas"),             mapOptions);      

} 

マップが読み込まれて正常に動作し、「200」がログに記録されます。jqxhr.status

OVER_QUERY_LIMITに対してgetScriptスローされた場合、API を使用して 403 エラーを処理できますか?

メソッドを取得するjqxhr.status=403か、使用する必要がありますfail(callback)か?

Jquery v1.7.2 を使用しています

4

1 に答える 1

0

ドキュメントを見てください:

$.getScript("ajax/test.js")
.done(function(script, textStatus) {
  console.log( textStatus );
})
.fail(function(jqxhr, settings, exception) {
  $( "div.log" ).text( "Triggered ajaxError handler." );
});
于 2012-08-22T11:12:13.273 に答える