Y130 / coderlikeadog.github.com

my tech blog
http://coderlikeadog.github.com
1 stars 0 forks source link

FileAPI图片上传IE7/8/9若干问题 #5

Open Y130 opened 9 years ago

Y130 commented 9 years ago

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);