用kindeditor上传图片,怎么设置请求头信息请输入代码
function _ajax(url, fn, method, param, dataType) {
method = method || 'GET';
dataType = dataType || 'json';
var xhr = window.XMLHttpRequest ? new window.XMLHttpRequest() : new ActiveXObject('Microsoft.XMLHTTP');
xhr.open(method, url, true);
xhr.onreadystatechange = function () {
if (xhr.readyState == 4 && xhr.status == 200) {
if (fn) {
var data = _trim(xhr.responseText);
if (dataType == 'json') {
data = _json(data);
}
fn(data);
}
}
};
if (method == 'POST') {
var params = [];
_each(param, function(key, val) {
params.push(encodeURIComponent(key) + '=' + encodeURIComponent(val));
});
try {
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
} catch (e) {
};
} else {
xhr.send(null);
}
}
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
用这个他们默认的设置,以及直接在header里面修改都是无效的,应用怎么设置,有同学遇到过吗?
同问,也遇到这个问题!