【发布时间】:2016-04-26 18:49:35
【问题描述】:
我在使用 Firefox 时遇到了多个问题,但在 chrome 中没有。
1) TypeError 中的问题:response.body 为空。
2) 上传图片时出现 TypeError: Argument 1 of FormData.constructor does not implement interface HTMLFormElement.
显示问题的代码是
对于 1 号问题(我为此使用了 superagent)
search( query='Ganesh Chowk' ){
let url = "/api/v1/rental/?place__startswith="+encodeURIComponent(query);
Request.get(url).then((response) => {
if (response) {
this.setState({
place:response.body.objects,
});
} else {
this.setState({
place: [],
});
}
});
第二期
let image = [];
class RenderPhotos extends React.Component {
constructor(props, context) {
super(props, context);
this.state = {
files: []
};
}
onDrop(files) {
console.log('Received files: ', files);
this.setState({
files: files
});
image = new FormData(files);
$.each(files,function(i,file){
image.append('image',file);
});
}
为什么这段代码在 chrome 上运行而不在 Firefox 上运行?要使此代码在所有浏览器中运行,应该进行哪些更改?
【问题讨论】:
标签: javascript ajax reactjs form-data superagent