On 2009/5/15, newbie <mara.ku...@gmail.com> wrote:
> hi,
>
>         Thanks for the reply.
>
> So suppose i call the ajax function like this.
>
>                       var args = { type:"POST", url:"district",
> data:data, complete:done };
>                        $.ajax(args);
>
> where data is the data to be posted and done is the function dat
> recieves the response.
> Is it enuf if a make an entry in urls.py as below
>
>        (r'^district$', view_to_be_executed),

Yes, absolutely. Remember to make sure that view_to_be_executed
returns an HttpResponse object, although the content will contain JSON
rather than HTML. Something like:
    return HttpResponse(simplejson.dumps(choices_list))

A minor side point: I'd question whether POST is the right method to
use here - you're not updating anything on the server, you're simply
requesting a new set of values dependent on an existing value. I would
do
    $.get('/district/' + district_id + '/', done);
and have the url as
    (r'^district/(?P<district_id>\d+)/$', view_to_be_executed),
so then district_id is a paramater to the view function.

--
DR.
--~--~---------~--~----~------------~-------~--~----~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to