鍍金池/ 問答/HTML/ kindeditor 富文本編輯器怎么設(shè)置header頭信息?

kindeditor 富文本編輯器怎么設(shè)置header頭信息?

用kindeditor上傳圖片,怎么設(shè)置請求頭信息請輸入代碼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');
用這個他們默認(rèn)的設(shè)置,以及直接在header里面修改都是無效的,應(yīng)用怎么設(shè)置,有同學(xué)遇到過嗎?

回答
編輯回答
解夏

同問,也遇到這個問題!

2018年2月23日 19:11