Skip to content

Instantly share code, notes, and snippets.

@trev
Created October 8, 2012 04:30
Show Gist options
  • Save trev/3850735 to your computer and use it in GitHub Desktop.
Save trev/3850735 to your computer and use it in GitHub Desktop.
<script type="text/javascript" src="statics/js/jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('#fire').click(function() { // This event fires when a button is clicked
var obj = $('#inputext').val();
$.ajax({ // ajax call starts
url: '/activity/', // JQuery loads serverside
data: 'obj=' + obj, // Send value of the clicked button
dataType: 'json', // Choosing a JSON datatype
success: function(data) // Variable data contains the data we get from serverside
{
$('#inputext').val('testing');
}
});
return false; // keeps the page from not refreshing
});
});
</script>
<textarea rows="10" cols="100" id="inputext">
</textarea>
{% if obj %}
<p>{{ obj }}</p>
{% endif %}
</br>
<button class="fire" name="fire" id="fire" type="submit">Submit</button>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment