Thanks. Actually I m using a lib called prototype where its returning the
csrfmiddlewaretoken. I have tested the alert in my function and its
returning the csrf token correctly. I m sending the color to the html page.
I tried using both chrome and firefox with firebug and chrome doesnt do
anything whereas firefox with firebug is telling me that my js/ajax
function doesnt exist. I have been getting the 403 response so I added the
csrf token to the data.


On Tue, May 15, 2012 at 7:03 PM, Kurtis Mullins <kurtis.mull...@gmail.com>wrote:

> I'll try to help out a bit.
>
> The first problem I see is in your Javascript. I believe your JQuery
> selector is supposed to be the field's ID -- so, for example,
> $("#csrfmiddlewaretoken").
> Next, in your view -- I don't see where you're actually returning any
> data. You should use Firebug or the Chrome Console to see what the actual
> response is that you're getting from the server when you perform the AJAX
> request.
>
> Give those a shot and us know if you still need any help. Good luck!
>
> On Tue, May 15, 2012 at 7:00 PM, Joel Khan <us1...@gmail.com> wrote:
>
>> I have a form that is used to add an item where 2 dropdowns are populated
>> using different database than the database where the form will be
>> submitted. I would like to add AJAX to the drop downs where selecting one
>> item in the first drop down will auto populate data in the 2nd drop down
>> using AJAX. The issue is that I am using the same view for the form to
>> populate the data and its not working even though I m using the is.ajax()
>> call.
>>
>> Here is my AJAX code:
>> function get_data(){ // alert('test'); new Ajax.Request('/abc/abc/add', {
>> method: 'POST', parameters: $H({'type':$('id_data').getValue()},
>> {'csrfmiddlewaretoken':$( "csrfmiddlewaretoken" ).getValue()}), onSuccess:
>> function(transport) { var e = $('id_def') if(transport.responseText)
>> e.update(transport.responseText) } }); // end new Ajax.Request //alert($(
>> "csrfmiddlewaretoken" ).getValue()); }
>> Here is my view code:
>>
>> if request.is_ajax(): #if request.is_ajax() cur =
>> connections['data'].cursor() #auto_type =
>> Auto.objects.filter(type=request.POST.get('type', '')) abctype =
>> request.POST.get('type', '') SQL = 'SELECT uuid FROM abc_abc where uid =
>> %s', abctype cur.execute(SQL) auto_type =cur.fetchone()
>>
>> cur = connections['data'].cursor() SQL = 'SELECT uuid, name FROM abc_abc
>> where parent_id = %s', auto_type cur.execute(SQL) colors = cur.fetchall()
>> return render_to_response('abc/add_abc.html', { 'colors' : colors, },
>> context_instance=RequestContext(request))
>>
>> Is there anything else that I m missing? Please let me know if you would
>> like me to add some more things from the code.....Please help!!
>>
>> Just to clearify i m using  this example from the web.
>> http://bradmontgomery.net/blog/a-simple-django-example-with-ajax/
>> >
>>
>> --
>> 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.
>>
>
>  --
> 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.
>

-- 
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