jquery - ajax response a django form using HttpResponse -


my ajax function has response django form.

in views.py code, .. .. dictionary={'userform':userform,'info_form':info_form} return httpresponse(dictionary) 

but when alert on console.log response like.. userforminfo_form. can not parse in json type @ both client n sever side. how httpresponse form object. when trying json.dump, gives me error that, json object not serializable. thanx!

you can use from django.core import serializers , can parse data coming database , create dict , and pass dict httpresponse

`userform = serializers.serialize('json', userform)` `dictionary={'userform':userform}` `httpresponse(json.dumps(dictionary),content_type="application/json"`) 

if it's doesn't work have parse data , create list follows

array=[] in data;     array.append(a) dictionary={'userform':array} httpresponse(json.dumps(dictionary),content_type="application/json") 

Comments

Popular posts from this blog

wireshark - USB mapping with python -

c++ - nodejs socket.io closes connection before upgrading to websocket -

Deploying Qt Application on Android is really slow? -