@DR: Yeah...you are right and that is why even i was confused with the
error. Finally i phrased out the problem and it was because i did not
restart the server after making changes to the view. In development
environment, it automatically done but when we deploy it on apache
server, its not. So that created the problem. Thanks for the reply.



On Jun 10, 4:47 pm, Daniel Roseman <roseman.dan...@googlemail.com>
wrote:
> On Jun 10, 10:50 am, newbie <mara.ku...@gmail.com> wrote:
>
>
>
> > Hi,
>
> >          I have written a small javascript ajax code in my django
> > application. Its working fine in the development environment. But when
> > i use the same code in the same django application running on apache
> > and also on  a different url(if it matters), it is not working. I have
> > tried using Firebug debugger. It is showing UnboundLocalError at /
> > identity/ajax_districts/
>
> > It says local variable &#39;state&#39; referenced before assignment
>
> > in urls.py
> > (r'^identity/ajax_districts/$',ajax_districts),
>
> > I have a funtion ajax_districts defined in my view identity.py
> > def ajax_districts(request):
> >         from django.utils import simplejson
> >         import logging
> >         logging.error("Came here")
> >         districts = {}
> >         districts[0] = "Nizamabad"
> >         json = simplejson.dumps(districts)
> >         return HttpResponse(json, mimetype="application/json")
>
> > in template:
>
> > <script type="text/javascript">
>
> > function getdistricts(state){
> >         alert("getdistricts");
> >         $.post("/identity/ajax_districts/", {"state":state},
> >                 function(data){
> >                         alert("getdistrict2s");
> >                 }, "json");
> >         alert("getdistrict1s");
>
> > }
>
> > $(document).ready(function(){
> > //              alert($("#id_state").val());
> > //              getdistricts($("#id_state").val());
>
> >                 $("#id_state").change(function(){
> >                         getdistricts($("#id_state").val());
> >                         });
>
> > //              alert($("#id_district").val());
> >                 });
>
> > </script>
>
> > Here id_state is the id of a select box
>
> > Can someone help me in this regard.
>
> > I hope i made myself clear. Do reply if i havent made myself clear.
>
> You haven't, unfortunately. The error message you quote appears to be
> a Python error, but the Python code you have posted does not use the
> name 'state' anywhere. You need to post the actual code that is
> causing the error, as shown in the traceback.
> --
> 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