file.setAttribute('accept','你的值')
$.post() 不支持加入 headers 信息,改用 $.ajax()。demo 如下:function getCode(param, config, notice) {
var url = config.apiBase
+ "/resource/"
var data = {
"name": param.name,
"user_agent": param.ua,
"mobile": $("#phone").val()
}
$.ajax({
url: url,
type: 'post',
data: data,
headers: {
"X-Requested-Accept": 'json'
},
dataType: 'json',
success: function (data) {
console.log(data)
if (data.ret) {
notice.showMsg({
msg: "短信验证码已经发送。",
type: "info",
deley: 0,
duration: 0,
close: true
})
countDown()
} else {
notice.showMsg({
msg: "短信验证码发送失败。",
type: "error",
deley: 0,
duration: 0,
close: true
})
}
}
})
}