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

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -