Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save crowdfundhq/19b00ffbdff2bbb0d574253b1d1713d2 to your computer and use it in GitHub Desktop.
Save crowdfundhq/19b00ffbdff2bbb0d574253b1d1713d2 to your computer and use it in GitHub Desktop.
<!-- This is an example on how to update contributions with jQuery from within your site -->
<p>The API says:</p>
<div id="response"></div>
<div id="error"></div>
<script>
document.addEventListener('DOMContentLoaded', function() {
var response = document.getElementById('response')
var error = document.getElementById('error')
$.ajax({
type:'POST',
url:'/api/v1/contribution/update',
data:{
campaign_id: '58772cb60aec087e67000014',
contribution_id: '58772cb60aec087e67000019',
amount: 200
},
success: function(json) {
console.log(json.responseText)
response.innerHTML = json.responseText
error.innerHTML = ''
},
error: function (err) {
console.log(err.responseText)
error.innerHTML = err.responseText
response.innerHTML = ''
}
})
})
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment