jquery - Django ajax request fails with internal server error -


im trying ajax request django interal server error 500..surprisingly request going server fails when tries return response guess..

here view

views.py

@csrf_exempt     def getproductinfo(request):         to_json = {'name':'test'}         print "value of = ", to_json         try:             json_response = simplejson.dumps(to_json)         except (typeerror, valueerror) err:             print 'error:', err         print 'json_response = ', json_response         return streaminghttpresponse(json_response,content_type='application/json')  

ajax call

$.ajax({         async:false         ,url:'/getproductinfo'         ,type: 'post'         ,data: {session_id: '{{request.session.sessionid}}'}         ,success: function(msg){             alert('success')         }         ,error: function(msg){             alert("it erroed out")         }      }) 

urls.py

url(r'^getproductinfo',getproductinfo), 

please let me know how fix issue..thanks..

your exception handling broken. if error on deserializing json, json_response undefined. reference after exception block, in case nameerror not catch.


Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -