Sai Rajesh Sai Rajesh - 3 months ago 9
Javascript Question

how to hide loading image after load chart in d3?



$(document).on('click', '.tbtn', function(e) {
$('#loading-image').show();
if(error){
$('loading-image').hide();
else{
val = $('.barbtn input:checked').val();
draw_summary($.parseJSON(data['summary']),val);
draw_barchart($.parseJSON(data['barchart']),val);
draw_scatter($.parseJSON(data['table']),val);
$('#loading-image').show();
}
});





Here i have drawing charts using d3...charts are coming correctly but i need to set loading image when i onclick the button...this code is not working

how to set loading image when onclick the button?

Answer

$(document).on('click', '.tbtn', function(e) {
  $('#loading-image').show();
  $.ajax({
    success:function(result){
      val = $('.barbtn input:checked').val();  
      draw_summary($.parseJSON(data['summary']),val);
      draw_barchart($.parseJSON(data['barchart']),val);
      draw_scatter($.parseJSON(data['table']),val);
      $('#loading-image').hide();
    }
  });
});

Comments