11-4 上传视频后,跑完进度条100% 提示 请求失败
来源:
maBi99
2016-11-30
老师你好,卡在11-4有半个月了 各种问题
写回答
2回答
-
这是请求哪个请求 url 失败了?把请求失败的错误 err 打印出来看看
052016-12-01 -
maBi99
提问者
2016-11-30
_upload(body){ var that = this var xhr = new XMLHttpRequest() var url = config.qiniu.upload console.log(body) this.setState({ videoUploading: true, videoUploaded: false, videoUploadedProgress: 0 }) xhr.open('POST',url) xhr.onload = () => { if (xhr.status !== 200) { //AlertIOS.alert('请求失败') console.log(xhr.responseText) return } if (!xhr.responseText){ AlertIOS.alert('请求失败2') return } var response try{ response = JSON.parse(xhr.response) } catch (e) { console.log(e) console.log('parse fails') } console.log(response) if (response){ that.setState({ video: response, videoUploading: false, videoUploaded: true }) } } if (xhr.upload){ xhr.upload.onprogress = (event) => { if (event.lengthComputable){ var percent = Number((event.loaded / event.total).toFixed(2)) that.setState({ videoUploadedProgress: percent }) } } } xhr.send(body) },
注释的地方
00
相似问题