Created
June 28, 2012 10:06
-
-
Save fajran/3010415 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/javascript"> | |
function compute() { | |
var a = $('#value_a')[0].value; | |
var b = $('#value_b')[0].value; | |
$.ajax({ | |
url: '/compute/?a=' + a + '&b=' + b, | |
success: function(data) { | |
$('#result').html(data); | |
} | |
}); | |
} | |
</script> | |
<p> | |
a = <input type="text" name="a" id="value_a"/> | |
b = <input type="text" name="b" id="value_b"/> | |
a + b = <span id="result">...</span> | |
<button onclick="compute()">compute</button> | |
</p> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.http import HttpResponse | |
def compute(request): | |
a = int(request.GET['a']) | |
b = int(request.GET['b']) | |
c = a + b | |
return HttpResponse('%d + %d = %d' % (a, b, c)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment