I want to use spinner while process foreach loop in php.
My functing is:
I am creting events using google calendar API in php.
for each of my array values I am creating event. and after each event create there is one sleep(5).
in this foreach loop I want to apply spinner. How to do this?

foreach ($myarray_name as $key  => $i) 
    $event_creted=gcal_event_create($event, $cal_id, 'test_name', $by_name = TRUE);
4 Years
Discussion Span
Last Post by JorgeM

The "spinner" is initiated client side, not server side. While your foreach loop is happening server side, the browser is not aware of what is going.

When the client side event is initiated say by a button click or something, is this call made back to the web server via Ajax, or is it a postback, or new page?

if its simply that a button was clicked on the page and something is happening server side waiting for a new page to load, you could initiate that spinner at the time the button was clicked. Many people use an animated gif to similuate some type of progress is happening in the background. I've found that the animated gifs dont always provide a good experience. Instead, i've been using javascript to create the spinner on the page. Take a look at: http://fgnass.github.io/spin.js/

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.