When working with an API action that takes around 10 seconds to retrieve data, I typically use an alert to ensure the data is successfully fetched. However, my main concern is how to effectively transmit this data to a Rails view for displaying purposes. Below is a snippet of my JavaScript code:
$.ajax({
type:"GET",
url:"pages/splunk_bf_data",
action:"splunk_bf_data",
dataType:"json",
success:function(data){
alert(data);
splunk_bf_data = data;
}
})
The slow API action resides on a separate page 'pages/splunk_bf_data' in order to expedite rendering on the current page.