Don't know if this will help, but when I use AJAX, I don't set the mimetype in HttpResponse(), I just pass simplejson.dumps() to HttpResponse():
return HttpResponse(simplejson.dumps(response)) This approach works with Firefox, IE6, & IE7. On Wed, 2009-06-10 at 02:50 -0700, newbie 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 'state' 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. > -- Adam Stein @ Xerox Corporation Email: a...@eng.mc.xerox.com Disclaimer: Any/All views expressed here have been proven to be my own. [http://www.csh.rit.edu/~adam/] --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---