报错:
ecause its MIME type ('application/json') is not executable, and strict MIME type checking is enabled.
接口返回的是base64格式
写的代码如下:
$("#contract_btn").click(function() {
$.ajax({
url: 'XXX',
data: {rfqId: openbidlog.rfqid, billType: "openBid"},
type: "GET",
Content-Type:application/json,
async: true,
success: function(data) {
}
})
})
参考借鉴来源:文心一言给出的解释
确保你的 AJAX 请求没有配置错误,特别是与响应数据类型(dataType)相关的配置。由于你期望的是 Base64 字符串,通常不应该设置 dataType: 'json'。如果你没有显式设置 dataType,jQuery 会尝试根据响应的 Content-Type 头来推断数据类型。如果服务器响应的 Content-Type 是 application/json,但数据实际上是 Base64 编码的字符串,这可能会导致问题。尝试显式设置 dataType: 'text'。
因为我的响应是base64 ,所以我得写响应数据类型dataType: 'text'。
修改后
$("#contract_btn").click(function() {
$.ajax({
url: 'XXX',
data: {rfqId: openbidlog.rfqid, billType: "openBid"},
type: "GET",
dataType: 'text',
async: true,
success: function(data) {
}
})
})
就可以进入success函数了