Random example

In this example we will create a random number using python, and we will send it to the #result element.



ajax.py

import random
from dajax.core import Dajax
from dajaxice.decorators import dajaxice_register

@dajaxice_register
def randomize(request):
    dajax = Dajax()
    dajax.assign('#result', 'value', random.randint(1, 10))
    return dajax.json()

html

<input type="text" value="" id="result">
<input type="button" onclick="Dajaxice.examples.randomize(Dajax.process)" value="Random!">