I agree with @Sam that this could be the background of the element, and all you would need to switch would be a class. If you configured it like this:
input { box-sizing: border-box; border: 1px solid #ccc; height: 30px; padding: 10px; } input.loading { background: url(http://www.xiconeditor.com/image/icons/loading.gif) no-repeat right center; }
And then you can switch the class when you make your ajax call, for example:
$(document).on('blur', 'input', function(e) { var $t = $(e.currentTarget); $t.addClass('loading'); $.ajax({ url: $t.data('ajax'), success: function(data) {
This, in my opinion, would be the easiest and most effective way to do this. If you want to look further here fiddle
source share