Q-上传成功后,若响应content-type=application/json,IE 7/8/9无法解析,会弹出保存文件提示
A- 设置content-type=text/plain
server-side以nodejs为例
var result = {"success":true,"url":"http://ip:port/12ab62ef.jpg"};result.statusText = JSON.stringify(result);result.status =200;res.set('Content-Type', 'text/plain');res.send(JSON.stringify(result));
client-side:
//xhr.statusText for IE7/8//xhr.responseXML for IE9//xhr.responseText||xhr.response for chrome & firefoxvar result = JSON.parse(xhr.responseText||xhr.response||xhr.statusText||xhr.responseXML);
Q-上传成功后,若响应content-type=application/json,IE 7/8/9无法解析,会弹出保存文件提示 A- 设置content-type=text/plain server-side以nodejs为例
var result = {"success":true,"url":"http://ip:port/12ab62ef.jpg"};
result.statusText = JSON.stringify(result);
result.status =200;
res.set('Content-Type', 'text/plain');
res.send(JSON.stringify(result));
client-side://xhr.statusText for IE7/8
//xhr.responseXML for IE9
//xhr.responseText||xhr.response for chrome & firefox
var result = JSON.parse(xhr.responseText||xhr.response||xhr.statusText||xhr.responseXML);