I feel your pain - javascript has always been a pain for me, but libraries like jQuery make it more bearable!
AJAX calls are made in the background (usually asynchronously), so they don't directly change the page you're currently viewing in your browser. The browser is responsible for dispatching the response returned from your AJAX call, typically by invoking a callback function you specified when the AJAX request was initiated. So you don't do a redirect from the server, rather you can do it using client side javascript in your callback function. Here is how it basically works: 1. Please Wait page makes AJAX request to run_DHM, specifies callback function when request completes. 2. run_DHM performs calculations, stores results in session, returns an "OK" response. 3. Browser invokes the callback function specified in step 1, which should change the page to display_DHM view. 4. display_DHM retrieves calculation results from session and renders HTML page. Your first problem is with the url template tag. You might try this: {% url MolProbity_Compare_test.views.run_DHM %} You can also use a named urls, e.g., ... url(r'^DHM_run/$', run_DHM, name="run_DHM"), ... in which case {% url run_DHM %} should also work Or you can just call the url directly instead of using the url template tag, e.g., '/run_DHM/'. The request argument is always passed to your views, you don't have to do it explicitly. So your run_DHM and display_DHM views will always have that available. Just get the session out of the request object in each view you need it. Basic skeleton: # please_wait.html ... <script type="text/javascript" src=" http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script> <script type="text/javascript"> $.get('{% url run_DHM %}', function(data) { if (data == 'OK') { window.location.href = '{% url display_DHM %}'; } else { alert(data); } }); </script> Note I've used the shorthand urls above, you could just use '/run_DHM/' and '/display_DHM/' instead of the url template tags. You could also use the full package path. Also note that the callback function I refer to is defined inline - the function(data) ... part. # views.py from django.http import HttpResponse def please_wait(request): return render_to_response('please_wait.html', ...) def run_DHM(request): # Do calculations, store results in request.session ... # If everything ok, return OK (otherwise return some error) return HttpResponse('OK') def display_DHM(request): # Get results from session return render_to_response('ran_DHM.html', ...) This is over simplified, but should serve to get started if you want to use this redirect approach. On Thu, Sep 9, 2010 at 9:59 AM, Bradley Hintze <bradle...@aggiemail.usu.edu>wrote: > Alec, > > Thanks for your patience. The jquery tutorials have been frustrating. > Anyway, I do not have three 'views' as you suggested. I will try that. > But I need to understand a few things before I try that. How to call > run_DHM from my please_wait.html page. (I assume AJAX but I've tried > and tries what have been suggested with no success, most likely due to > my failed attempts at understanding AJAX) I assume after I run the > run_DHM view function I will somehow have run_DHM redirect it to the > display_DHM. My question is, how do I redirect AND pass the > request.session arguments, which is where the data from run_DHM will > be stored? > > As requested, here is my full url.py: > > from django.conf.urls.defaults import * > from MolProbity_Compare_test.views import * > > # Uncomment the next two lines to enable the admin: > # from django.contrib import admin > # admin.autodiscover() > > urlpatterns = patterns('', > (r'^home/$', home_view),#the 'index' or home or top page view > (r'^about/$', about_view), > (r'^log_out_confirm/$', log_out_confirm), > (r'^log_out/$', log_out), > (r'^upload/$', uploaded_PDBs), > (r'^rotamer_diff/$', rotamer_dif_frame), > (r'^side-by-side/$', side_by_side), > (r'^side-by-side-key/$', side_by_side_key), > (r'^side-by-side-frame/$', side_by_side_frame), > (r'^DHM_run/$', run_DHM), > (r'^please_wait/', please_wait), > (r'^analyze/$', analyze_compare), > ) > > > On Thu, Sep 9, 2010 at 9:22 AM, Alec Shaner <asha...@chumpland.org> wrote: > > Could you post the full url.py file? > > > ... -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.