Javascript 当post正文内容为JSON但响应为HTML时发出jquery ajax post请求

Javascript 当post正文内容为JSON但响应为HTML时发出jquery ajax post请求,javascript,jquery,Javascript,Jquery,我提出以下jquery ajax post请求: $.ajax({ url: '/foo', type: 'post', dataType: 'html', data: JSON.stringify(barsJSON), success: function (responseHTML) { $('#

我提出以下jquery ajax post请求:

$.ajax({
                url: '/foo',
                type: 'post',
                dataType: 'html',
                data: JSON.stringify(barsJSON),
                success: function (responseHTML) {
                    $('#content').html(responseHTML);
                }

                });
服务器希望帖子正文内容为JSON类型,但服务器发送的响应是HTML。上述内容是否正确?

添加contentType

缺少内容类型示例:“application/json”

内容类型
添加
contentType:'application/json'

您应该在ajax调用中提到内容类型
例如:contentType:“application/json”

问题是什么?@dzambazov
type
method