I'm having a little problem with refreshing a tab and not a whole page in Ajax.
This tab concerns the removal of credit cards.
Once I select the credit card I want to delete and validate I use "window.location.reload ();
" which allows refreshing the whole page but suddenly it sends me back to "My profile" (see photo):
Before refresh:
After refresh:
While I want it refreshes only tab "means of payment" here is my code:
handleCardDelete = () => {
var numCard = $('input[name=rbCard]:checked').val();
console.log(this.state.token);
$.ajax({
url: 'http://API.....,
dataType: 'json',
type: 'DELETE',
headers: {
'Authorization' : 'Bearer ' + this.state.token
},
complete: function(){
alert("carte supprimée avec succès");
window.location.reload();
},
});
};
HTML
<Button animated='fade' onClick={this.handleAddCardSubmit}>
<Button.Content visible>
Ajouter une carte
</Button.Content>
<Button.Content hidden>
<Icon name='add' />
</Button.Content>
</Button>
<Button animated='fade' onClick={this.handleCardDelete}>
<Button.Content visible>
Supprimer la carte
</Button.Content>
<Button.Content hidden>
<Icon name='delete' />
</Button.Content>
</Button>
I hope I have been clear, I continue my research and I wish you a good day!