David Schumann
David Schumann

Reputation: 14793

201 created status code sent by django rest framework interpreted as failiure by jquery $.ajax call

I am simply using django-rest-frameworks CreateAPIView which returns a response containing a 201 status code.

I would expect this to work with the standard javascript/jquery ajax functions. But apparently it does not.

Here is a similar issue where Retrofit throws an error. Any Ideas on how to debug this on jquery?

Upvotes: 0

Views: 1166

Answers (1)

Jahongir Rahmonov
Jahongir Rahmonov

Reputation: 13753

My guess is that you are returning an empty string as a response from your Django view and in your ajax code you set dataType as json.

The problem is that empty string is an error for json.

That's why try to set dataType to text or just don't set it at all. Remove it from your code.

Hope it helps!

Upvotes: 1

Related Questions