Force content-type to text/plain in form's AJAX response to prevent HTML content-type
authorThierry Florac <thierry.florac@onf.fr>
Tue, 14 Oct 2014 14:34:41 +0200
changeset 84 67b61a2eb943
parent 83 782a12d62702
child 85 1b31fa7e2ca3
Force content-type to text/plain in form's AJAX response to prevent HTML content-type
src/ztfy/myams/form.py
--- a/src/ztfy/myams/form.py	Tue Oct 14 14:33:24 2014 +0200
+++ b/src/ztfy/myams/form.py	Tue Oct 14 14:34:41 2014 +0200
@@ -315,6 +315,7 @@
         if errors:
             return writer.write(self.getAjaxErrors())
         result = self.createAndAdd(data)
+        self.request.response.setHeader('Content-Type', 'text/plain; charset=utf-8')
         return self.getSubmitOutput(writer, result)
 
     def createAndAdd(self, data):
@@ -370,6 +371,7 @@
         if errors:
             return writer.write(self.getAjaxErrors())
         changes = self.applyChanges(data)
+        self.request.response.setHeader('Content-Type', 'text/plain; charset=utf-8')
         return self.getSubmitOutput(writer, changes)
 
     def applyChanges(self, data):