Thanks Andréas,

I will try it.

Regards/AR


El 28/08/2014 02:57 a.m., Andreas Kuhne escribió:
Hi Antonio,

import simplejson as json

return HttpResponse(
    json.dumps({
        'array': example
    }),
    content_type="application/json"
)

That would do the trick. This is returned as JSON. Remember to set the content_type, otherwise the client can get confused.

Regards,

Andréas

2014-08-28 2:56 GMT+02:00 Antonio Russoniello <aruss...@musicparticles.com <mailto:aruss...@musicparticles.com>>:

    Hello,

    i hope you can help me with this, I'm trying to send to an ajax
    (jquery from my html template) a response but i would like to send
    also a new variable.

    in my html template I have:

        $("#init_date").click(function(){
            var some_date = {'init_date': init_date, 'end_date':
    end_date};
            $.post("/filter_dates/", some_date, function(response){
                if(response === 'success'){
    /                MAKE SOMETHING//!!!/
                else{ alert('error'); }
            });
        });

    my django view look like:

    def filter_date(request):
        if request.method == 'POST':
            example = ['A','B','C']
            init_date = request.POST['init_date']
            end_date = request.POST['end_date']
             MAKE SOMETHING!!
            return HttpResponse('success') /AND HERE I WOULD LIKE TO
    SEND THE example ARRAY.../
        else:
            return HttpResponse('error')

    How can I send the array o some other variable as response?

    Regards,
    AR
-- You received this message because you are subscribed to the Google
    Groups "Django users" group.
    To unsubscribe from this group and stop receiving emails from it,
    send an email to django-users+unsubscr...@googlegroups.com
    <mailto:django-users+unsubscr...@googlegroups.com>.
    To post to this group, send email to django-users@googlegroups.com
    <mailto:django-users@googlegroups.com>.
    Visit this group at http://groups.google.com/group/django-users.
    To view this discussion on the web visit
    
https://groups.google.com/d/msgid/django-users/53FE7E44.4020104%40musicparticles.com
    
<https://groups.google.com/d/msgid/django-users/53FE7E44.4020104%40musicparticles.com?utm_medium=email&utm_source=footer>.
    For more options, visit https://groups.google.com/d/optout.


--
You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com <mailto:django-users+unsubscr...@googlegroups.com>. To post to this group, send email to django-users@googlegroups.com <mailto:django-users@googlegroups.com>.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CALXYUbnxRG8cs7_4-ALJUubXRPhx%2B2FQE1NA7bkTiBqoB1ySLw%40mail.gmail.com <https://groups.google.com/d/msgid/django-users/CALXYUbnxRG8cs7_4-ALJUubXRPhx%2B2FQE1NA7bkTiBqoB1ySLw%40mail.gmail.com?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/540136FE.9000809%40musicparticles.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to