Where’s my JSON data in my incoming Django request?

I’m trying to process incoming JSON/Ajax requests with Django/Python. request.is_ajax() is True on the request, but I have no idea where the payload is with the JSON data. request.POST.dir contains this: [‘__class__’, ‘__cmp__’, ‘__contains__’, ‘__copy__’, ‘__deepcopy__’, ‘__delattr__’, ‘__delitem__’, ‘__dict__’, ‘__doc__’, ‘__eq__’, ‘__ge__’, ‘__getattribute__’, ‘__getitem__’, ‘__gt__’, ‘__hash__’, ‘__init__’, ‘__iter__’, ‘__le__’, ‘__len__’, ‘__lt__’, ‘__module__’, ‘__ne__’, ‘__new__’, ‘__reduce__’, … Read more

Difference between application/x-javascript and text/javascript content types

What is the difference between these headers? Content-Type: application/javascript Content-Type: application/x-javascript Content-Type: text/javascript Which one is best and why? Please do not say they are identical – if they were identical there would not have been three of them. I know both work – but I would like to know the difference. 4 Answers 4

Jquery – How to make $.post() use contentType=application/json?

I’ve noticed that when using $.post() in jquery that the default contentType is application/x-www-form-urlencoded – when my asp.net mvc code needs to have contentType=application/json (See this question for why I must use application/json: ASPNET MVC – Why is ModelState.IsValid false “The x field is required” when that field does have a value?) How can I … Read more

Setting mime type for excel document

MS Excel has the following observed MIME types: application/vnd.ms-excel (official) application/msexcel application/x-msexcel application/x-ms-excel application/x-excel application/x-dos_ms_excel application/xls application/x-xls application/vnd.openxmlformats-officedocument.spreadsheetml.sheet (xlsx) Is there any one type that would work for all versions? If not, do we need to set response.setContentType() with each one of these mime types individually? Also, we use file streaming in our application to … Read more

HTML Input=”file” Accept Attribute File Type (CSV)

I have a file upload object on my page: <input type=”file” ID=”fileSelect” /> with the following excel files on my desktop: file1.xlsx file1.xls file.csv I want the file upload to ONLY show .xlsx, .xls, & .csv files. Using the accept attribute, I found these content-types took care of .xlsx & .xls extensions… accept= application/vnd.openxmlformats-officedocument.spreadsheetml.sheet (.XLSX) … Read more

How do you set the Content-Type header for an HttpClient request?

I’m trying to set the Content-Type header of an HttpClient object as required by an API I am calling. I tried setting the Content-Type like below: using (var httpClient = new HttpClient()) { httpClient.BaseAddress = new Uri(“http://example.com/”); httpClient.DefaultRequestHeaders.Add(“Accept”, “application/json”); httpClient.DefaultRequestHeaders.Add(“Content-Type”, “application/json”); // … } It allows me to add the Accept header but when I … Read more