The web service accepts application/json
, but $.ajax()
with dataType : 'json'
set just tries to send data as application/x-www-form-urlencoded
. What's the trick here?
Asked
Active
Viewed 348 times
0

Rápli András
- 3,869
- 1
- 35
- 55
-
Checkout this answer http://stackoverflow.com/a/18701357/1370442 notice you need to set contentType as well as dataType ;o) – Luke Baughan Sep 24 '14 at 17:33
1 Answers
2
dataType: 'json'
specifies that jQuery expects JSON back from the server (see docs). In order to specify that you are sending JSON, you need to add contentType: "application/json"
.
Furthermore, jQuery cannot convert an object into JSON for you. If you are passing any object to data
, you need to stringify it yourself:
data: JSON.stringify(dataObject);