From 76c8e33d495c2710035f7765f5b1afb566dada3f Mon Sep 17 00:00:00 2001 From: Christine Lytwynec Date: Fri, 15 Jan 2016 09:08:16 -0500 Subject: [PATCH] Fix file upload in IE --- lms/djangoapps/django_comment_client/base/views.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lms/djangoapps/django_comment_client/base/views.py b/lms/djangoapps/django_comment_client/base/views.py index 79ae6921bc..994e585e84 100644 --- a/lms/djangoapps/django_comment_client/base/views.py +++ b/lms/djangoapps/django_comment_client/base/views.py @@ -1,5 +1,6 @@ import functools import logging +import json import random import time import urlparse @@ -7,7 +8,7 @@ import urlparse from django.contrib.auth.decorators import login_required from django.contrib.auth.models import User from django.core import exceptions -from django.http import Http404, HttpResponseBadRequest +from django.http import Http404, HttpResponseBadRequest, HttpResponse from django.utils.translation import ugettext as _ from django.views.decorators import csrf from django.views.decorators.http import require_GET, require_POST @@ -750,13 +751,16 @@ def upload(request, course_id): # ajax upload file to a question or answer result = '' file_url = '' - return JsonResponse({ + # Using content-type of text/plain here instead of JSON because + # IE doesn't know how to handle the JSON response and prompts the + # user to save the JSON as a file instead of passing it to the callback. + return HttpResponse(json.dumps({ 'result': { 'msg': result, 'error': error, 'file_url': file_url, } - }) + }), content_type="text/plain") @require_GET