Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6651263
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:59:24+00:00 2026-05-26T00:59:24+00:00

I’m working through the random machine example , but I’m having trouble. I’ve installed

  • 0

I’m working through the random machine example, but I’m having trouble. I’ve installed Dajax and Dajaxice according to these two pages: Dajax and Dajaxice. My ajax.py file looks like this:

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()

Here’s my views.py:

from django.shortcuts import render_to_response
from django.template import RequestContext

def dajax(request):
     return render_to_response( 'dajax.html', context_instance=RequestContext(request) )

Here’s my urls.py:

from django.conf.urls.defaults import patterns, include, url
from dajaxice.core import dajaxice_autodiscover
from dajaxice import urls
from django.conf import settings
from Dajax.myapp.views import dajax
dajaxice_autodiscover()

urlpatterns = patterns('',
    (r'^%s/' % (settings.DAJAXICE_MEDIA_PREFIX), include('dajaxice.urls')),
    (r'^dajax/$', dajax),
)

My html form tag looks like this:

<form>
        <input type="text" name="result" value="" id="result">
        <input type="button" name="rand" value="Let's Rand!" id="rand" onclick="Dajaxice.myapp.randomize(Dajax.process); return false;">
</form>

Here’s what my head tag looks like:

<head>
    <title>My base template</title>
    {% dajaxice_js_import %}
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js" type="text/javascript" charset="UTF-8"></script>
    <script src="{{ STATIC_URL }}js/jquery.dajax.core.js" type="text/javascript" charset="UTF-8"></script>
</head>

I added the following to my init.py file in my project dir:

from myapp.ajax import randomize

Also of note, my Django app’s name is myapp.

On my page, when I click on Let’s Rand!, the page goes to http://localhost:8000/dajax/?result=2, and no value shows up in the text input box. I checked the console in Chromium and there aren’t any errors.

Did I incorrectly install either Dajax or Dajaxice, or is there something wrong with my code above?

My guess is that because I’m using jQuery instead of Prototype, there’s something different I need to do.

Thanks for your help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T00:59:25+00:00Added an answer on May 26, 2026 at 12:59 am

    You need a return false; in your onClick handler after the call to Dajax.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
Seemingly simple, but I cannot find anything relevant on the web. What is the
I want to count how many characters a certain string has in PHP, but
I am trying to loop through a bunch of documents I have to put
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I need to clean up various Word 'smart' characters in user input, including but
I want use html5's new tag to play a wav file (currently only supported
Does anyone know how can I replace this 2 symbol below from the string
this is what i have right now Drawing an RSS feed into the php,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.