I have a page which lists a number of jobs, each job has a button for paid and the button has a data-paid attribute which contains the value of whether it's paid or not.
When the button is clicked, I send a request to my route which updates the payment and returns success along with the status whether its paid or not.
See my button.
<button data-id="{{ $r->id }}" data-paid="{{ $r->paid }}" class="btn btn-success btn-sm paid">Paid</button>
When clicked
$('button.paid').on('click', function() {
var job = this;
var id = $(this).data("id");
$.get('/round/job/' + id + '/paid', function(data){
$(job).data('paid',data.jh.paid);
console.log(data.jh.paid);
});
});
When looking at the console, if paid the route returns 1, if not paid it returns 0.
I want to update the data-paid attribute against the button with the value of either 1 or 0.
I thought function would do that but it doesn't update the value it remains at the value when the page is loaded.