我正在发出以下 jquery ajax post 请求:
$.ajax({
url: '/foo',
type: 'post',
dataType: 'html',
data: JSON.stringify(barsJSON),
success: function (responseHTML) {
$('#content').html(responseHTML);
}
});
服务器期望帖子正文内容为 JSON 类型,但服务器发送的响应是 HTML。以上正确吗?
最佳答案
添加内容类型
示例内容类型:'application/json'
关于javascript - 当帖子正文内容为 JSON 但响应为 HTML 时,发出 jquery ajax post 请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50410051/