Relevant Stack Overflow question/answer: http://stackoverflow.com/a/9970672/447485
In short, you can't do it over simple Ajax, but you can emulate it. Cheers, AT On Thu, Apr 24, 2014 at 8:56 AM, Tom Evans <tevans...@googlemail.com> wrote: > On Thu, Apr 24, 2014 at 4:31 AM, 张永强 <shoumu...@gmail.com> wrote: > > > > In my program, I want to generate a pdf and output to the browser. > > > > the server end code is: > > > > response = HttpResponse(content_type='application/pdf') > > response['Content-Disposition'] = 'attachment; filename="' + orderNumber > + '.pdf"' > > response.write(pdf) > > return response > > > > In the code, the type of pdf is 'str' > > > > the ajax code is: > > > > $.ajax({ > > type:'POST', > > url:'/orderplace/', > > data:{provider:provider, providerId:providerId, > orderNumber:orderNumber}, > > success:function(resultData) { > > ; > > } > > }); > > You cannot download files with AJAX. Make a regular request. > > Cheers > > Tom > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to django-users+unsubscr...@googlegroups.com. > To post to this group, send email to django-users@googlegroups.com. > Visit this group at http://groups.google.com/group/django-users. > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-users/CAFHbX1JES94hqHGNkcacE65s_qAuJ6nK%3Db7gT6RaynmxeFopng%40mail.gmail.com > . > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAKBiv3zfknfnb%2B1Gd_5S3AB6Da7VX%2BjW5wWaCyTC6b9oTD%2B2pw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.