Error 415: x
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?
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);
链接地址: http://www.djcxy.com/p/46162.html
下一篇: 错误415:x