In this example we will create a random number using python, and we will send it to the #result element.
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()
<input type="text" value="" id="result"> <input type="button" onclick="Dajaxice.examples.randomize(Dajax.process)" value="Random!">