sample ajax request

This commit is contained in:
Rimian Perkins
2017-02-15 14:10:52 +11:00
parent 4d2c52e3f2
commit e1778d6bd8
4 changed files with 42 additions and 19 deletions
@@ -1,10 +1,17 @@
import { ajax } from 'discourse/lib/ajax';
export default Ember.Controller.extend({
user: Ember.inject.controller(),
username: Ember.computed.alias('user.model.username_lower'),
email: Ember.computed.alias('user.model.email'),
actions: {
choiceTest: function() {
makePayment: function() {
ajax('/payments', { method: 'POST' }).then(() => {
console.log(this);
});
this.set('saved', true);
}
}
@@ -2,10 +2,10 @@
{{username}}
</div>
<button class='btn btn-primary choice-btn' {{action "choiceTest"}}>
click
<button class='btn btn-primary payment-btn' {{action "makePayment"}}>
make payment
</button>
{{#if saved}}
<div class="choice-response">Response happens</div>
<div class="payment-response">Response happens</div>
{{/if}}