Skip to content

Instantly share code, notes, and snippets.

@Olefine
Created May 21, 2013 11:14
Show Gist options
  • Save Olefine/5619067 to your computer and use it in GitHub Desktop.
Save Olefine/5619067 to your computer and use it in GitHub Desktop.
json ajax rz2
$(document).ready ->
$('div#reload_form form').submit (event) ->
event.preventDefault()
form = $(this)
url = form.attr('action')
ammo = $('#ammo_to_reload').val()
$.ajax
type: 'put'
url: url
data: {ammo_to_reload: ammo}
dataType: 'json'
success: (json) ->
$('#ammo').text(json.ammo).effect("highlight")
$('#reload_form').fadeOut() if json.ammo >= 30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment