Skip to content

Instantly share code, notes, and snippets.

@naoyeye
Created June 15, 2018 07:30
Show Gist options
  • Save naoyeye/0b708a52d05c81d85d0386a470b21688 to your computer and use it in GitHub Desktop.
Save naoyeye/0b708a52d05c81d85d0386a470b21688 to your computer and use it in GitHub Desktop.
// =====html
<input type="number" name="price" />
<button class="btn buy">做多</button>
<button class="btn sell">做空</button>
// =====js
const accounts = [
{
'name': 'account-1',
'api': 'http://xxx'
},
{
'name': 'account-2',
'api': 'http://xxx'
}
{
'name': 'account-3',
'api': 'http://xxx'
}
{
'name': 'account-4',
'api': 'http://xxx'
}
]
$('button').click((e) => {
var actionType // 做多还是做空
if ($(this).hasClass('buy')) {
actionType = 'buy'
} else {
actionType = 'sell'
}
var price = $('input[name="price"]').val()
$.each(accounts, (account) => {
$.ajax({
url: account.api,
data: { price: price, actionType: actionType, accountId: account.id },
success: function(resp) {
console.log(resp)
}
})
})
})
@onestarshang
Copy link

🍨

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment