ajax - Display a pending icon when status is pending and Display a completed icon when status is completed -


the general design

i want able display pending status icon in area when request still pending , status of request pending, want display completed status icon when request returns status of completed.

in handlebars:

{{!-- status --}}   {{#each search.data |status|}}     {{#if statuspending}}       <p><span><i class="glyphicon glyphicon-option-horizontal"></i></span>&nbsp;</p>     {{else}}       <p><span><i class="glyphicon glyphicon-ok"></i></span>&nbsp;</p>     {{/if}}   {{/each}} 

statuspending being action check status.

i thinking like:

actions: {     statuspending: function() {         if ('status' == 'pending') {             ember.$.ajax({                 type: 'get',                 url: https://linktothing.com/slash/,                     return: true,             })         }     } } 

where status in header of request , pending returns.

that i've got far... doesn't work (of course). suggestion, code or links relevant reading material welcomed. returning true satisfies if/else statement in handlebars , therefore show false - completed if not true.

update

answer worked case.

didinsertelement: function() {       var _thing = this.get('thing');        this.set('ispending', _thing.status === 'pending'); }, 

it should this:

{     ispending: false    checkstatus: function() {     ember.run.later(this, function() {         ember.$.ajax(/* code here */).then(function(response) {         if (response.status == 'finished status') {             this.set('ispending', false);         } else {             this.checkstatus();         }       }.bind(this))     }, 5000); //check every 5 seconds   }      actions: {     startasyncoperation: function() {         this.set('ispending', true);       this.checkstatus();     }   }  }