我不明白爲什麼這是在控制檯中投擲Cannot convert a Symbol value to a string
。我正在使用React v15和jQuery v3。無法將符號值轉換爲字符串 - 反應AJAX刪除請求
這裏是我的陣營代碼:
var CommentList = React.createClass({
handleDelete: function(comment) {
console.log(comment);
$.ajax({
url: this.props.url,
dataType: 'json',
type: 'DELETE',
data: comment,
contentType:'application/json',
dataType: 'text',
success: function(data) {
this.setState({ data: data });
}.bind(this),
error: function(xhr, status, err) {
this.setState({data: comments});
console.error(this.props.url, status, err.toString());
}.bind(this)
})
},
render: function() {
var commentNodes = this.props.data.map(comment => {
return(
<div key= { comment.id }>
<Comment author = { comment.author }>
{ comment.text }
</Comment>
<button onClick={this.handleDelete}>delete</button>
</div>
);
});
return (
<div className="commentList">
{commentNodes}
</div>
);
}
});
JSON文件看起來像:
[
{
"id": 1388534400000,
"author": "Pete Hunt",
"text": "Hey there!"
},
{
"id": 1323434400000,
"author": "Ben Jerry",
"text": "I did a thing"
},
...
...
]
'error'回調的'err'變量是什麼? – Sojtin