Skip to content

Instantly share code, notes, and snippets.

@mojaray2k
Created March 16, 2013 05:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mojaray2k/5175104 to your computer and use it in GitHub Desktop.
Save mojaray2k/5175104 to your computer and use it in GitHub Desktop.
This is a jQuery Ajax Template 1
var fetchingFlights = null;
function showFlights(e){
$('tabs div').hide();
$(activeDiv).show();
var flight = $(this).data('flight');
var flightClass = $(this).data('class');
if(fetchingFlights.abort){
fetchingFlights.abort();
}
var fetchingFlights = $.ajax('/flights', {
data: { date: activeDiv },
timeout: 8000,
cache: false,
beforeSend: function(){
$('error').hide();
$('loading').show();
},
complete: function(){
$('loading').hide();
},
success: function(result){
$(activeDiv).html(result);
$(activeDiv).show();
},
error: function(result){
if(result.statusText != 'abort'){
$('#tabs #error').show();
}
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment