简体   繁体   中英

Button with image and loading element id when clicked

I've made an application that makes full use of ajax, and what I need to do is: I want a button with a description + image that when clicked is disabled and instead of the original image in the button, appears the ajax loading element id inside the button. And when the ajax loading is complete, the original image of the button returns to the normal.

Is there any good source on how to do something like this? What do you guys suggest?

if your button is image you can just change it's source like this

 
function call_my_method(el)
{
  //ajax call and stuff
 el.setAttribute('src', 'loading.gif');
}

and all you have to do is return old image once you get response from server, same way as you put the loading.gif

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM