lay-upload 组件,在ie8/ie9下无法获取data{}中的数据,ie10,chrome可

提问 未结
2 198
ahui
ahui 2017-9-14
悬赏:10飞吻
碰到一个问题,lay-upload 组件,在ie8/ie9下无法获取data{}中的数据,ie10,chrome可以正常获取
回帖
  • 光光
    2017-12-27
    iframeSend = function() {
    var iframe = $('#' + ELEM_IFRAME);
    that.elemFile.nextAll().remove();
    that.elemFile.after(function() {
    var arr = [];
    layui.each(options.data, function(key, value) {
    if (key !== options.field)
    arr.push('<input type="hidden" name="' + key + '" value="' + value + '">');
    });
    return arr.join('');
    }());
    that.elemFile.parent().submit();
    that.elemFile.nextAll().remove();
    //获取响应信息
    clearInterval(Class.timer);
    Class.timer = setInterval(function() {
    var res, iframeBody = iframe.contents().find('body');
    try {
    res = iframeBody.text();
    } catch (e) {
    that.msg('获取上传后的响应信息出现异常');
    clearInterval(Class.timer);
    error();
    }
    if (res) {
    clearInterval(Class.timer);
    iframeBody.html('');
    done(0, res);
    }
    }, 30);
    }
    0 回复
  • 光光
    2017-12-27
    //统一回调
    , done = function (index, res) {
    that.elemFile.next('.' + ELEM_CHOOSE).remove();
    elemFile.value = '';
    if (typeof res !== 'object') {
    try {
    if (device.ie && device.ie < 8)
    res = (new Function("return " + res))();
    else
    res = JSON.parse(res);
    } catch (e) {
    res = {};
    return that.msg('请对上传接口返回有效JSON');
    }
    }
    typeof options.done === 'function' && options.done(res, index || 0, function (files) {
    that.upload(files);
    });
    }
    0 回复
本帖已设置禁止回复
本周热议
没有相关数据
layui

微信扫码关注 layui 公众号