Any idea for loading animation workaround?

Any idea for loading animation workaround?

On my application i have page with ZML <image>  which has attribute action='Function'.
when the image (icon) pressed a function get called and sometimes the function takes some time (API Calls). 

For making a reasonable UX i would like to show a sign to the user that something is happening behind the scenes. loading animation can be great but a i don't find a way to do it.

did anyone solved this before? 

Thanks