Tuesday, August 31, 2010

Re: Please wait page trouble

I'll look into this. I have no idea what you mean by 'ajax' or 'json'.
Thus your code doe'snt really make sense given my lack of knowlege. I
will do some googling to see if I can piece it together. Thanks for
the help!

On Mon, Aug 30, 2010 at 10:37 PM, Rolando Espinoza La Fuente
<darkrho@gmail.com> wrote:
> On Mon, Aug 30, 2010 at 7:18 PM, Bradley Hintze
> <bradley.h@aggiemail.usu.edu> wrote:
>> I am attempting to do a lengthe calculation that will require the user
>> to wait a bit. I want a 'Please wait page to come up while the lengthy
>> calculation is performed. I thought this might work:
>>
>> views.py
>>
>> def please_wait(request):
>>    return HttpResponse('Please Wait......')
>>
>> def run_DHM(request):
>>    please_wait(request)
>>    ....lengthy calculations...
>>
>> This did not show the 'Please Wait' page. Is there a better way to do
>> what I am trying to do?
>>
>
> You are not returning the HttpResponse object from please_wait(). But anyway,
> doesn't work that way. At least with django.
>
> What you can do is render a normal html with the message "Please wait",
> then perform an ajax call to start the calculations and finally return
> a json response
> to display the result in the client-side.
>
> Roughly:
>
> def please_wait(request):
>    # ... setup context or something
>    return render_to_response("please_wait.html")
>
> def run_DHM(request)
>    # ... perform calculations and collect the result in a dict
>    data = {"result": something}
>    return HttpResponse(json.dumps(data), mimetype="application/json")
>
>
> # using jquery in your html
> <script type="text/javascript">
> $.getJSON("/run_DHM/", function(data) {
>    // do something with result
>    console.log(data.result);
> });
> </script>
>
>
> Rolando Espinoza La fuente
> www.insophia.com
>
>> --
>> Bradley J. Hintze
>> Graduate Student
>> Duke University
>> School of Medicine
>> 801-712-8799
>>
>> --
>> You received this message because you are subscribed to the Google Groups "Django users" group.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
>> For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
>>
>>
>
> --
> You received this message because you are subscribed to the Google Groups "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
>
>

--
Bradley J. Hintze
Graduate Student
Duke University
School of Medicine
801-712-8799

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment