0
handleAddUser(){
if(this.checkRequiredField()){
$.ajax({
url:this.state.location,
datatype:'text',
type:'POST',
data:{
UserId:this.state.userId,
AccountName:this.state.accountName
},
success:function(data,statuc,xhr){
console.log(xhr.getResponseHeader('Location'));
console.log('data added successfully');
this.updateUserList(xhr.getResponseHeader('Location'));
},
error:function(xhr,status,err){
console.error(status, err.toString());
}
});
}
}
在上面的post請求中,它的成功函數有一個方法來更新用戶列表。TypeError:this.updateUserList不是函數。 reactjs
updateUserList方法定義並在構造函數中提到這樣
this.updateUserList = this.updateUserList.bind(this);
,但沒有被執行的方法,而不是我在瀏覽器控制檯
TypeError: this.updateUserList is not a function
下面的錯誤。
我在另一個屏幕上有類似的代碼,它按預期工作。 如何解決這個問題?
感謝@Shubham卡特里範圍出現問題。 – MemoryLeak