#Incoming Counts Issues

1 messages · Page 1 of 1 (latest)

upper hare
#

You'd need some sort of reloading for that to happen, like through polling or websockets/broadcasting.

steel mulch
#

please how do i sort the reloading

upper hare
#

IDK, all you've shared is a screenshot and "it doesn't work". We don't know what stack you're using, how this data is stored, like through an XHR request etc

steel mulch
#

using ajax

#

<script>
$(document).ready(function() {
$(document).on('click', 'button[data-bs-target="#assign"]', function() {
var clientName = $(this).data('client-name');
var jobNumber = $(this).data('job-number');
var serviceId = $(this).data('case-id');
$('#jobNumber').val(jobNumber);
$('#clientName').val(clientName);
$('#serviceId').val(serviceId);
$('#assign').modal('show');
});
$('#assignForm').submit(function(event) {
event.preventDefault();
var formData = $(this).serialize();
var serviceId = $('#serviceId').val();
$.ajax({
url: "{{ route('store.assigned.case') }}",
method: 'POST',
data: formData,
success: function(response) {
toastr.success(response.message);
// Remove the assigned case row from the table
$('#assignedCaseRow' + serviceId).remove();

                    // Update the counts dynamically
           $('#totalApplication').text(response.incomingApplicationCount);

$('#assignedClientCount').text(response.assignedClientCount);

                    $('#assign').modal('hide');
                    location.reload();
                },
                error: function(xhr, status, error) {
                    console.error(error);
                    toastr.error('An error occurred while assigning the case.');
                }
            });
        });
        $('#assignCloseBtn').click(function(event) {
            event.preventDefault();
            $('#assign').modal('hide');
        });
    });
</script>

i added a reload() but then before it reloads the count shows 0 for incomingapplication

#

please have i well explained i t

upper hare
#

IDK what to say really. You'd first have to think about how you want this to work in the first place. You're making an XHR request, so that means nothing on the page would be updated in the first place. You'd need to fetch that new data and update the page, like through another XHR request, or by returning the data and using that to modify the page.

steel mulch
#

oh okay

#

are you on whatsapp

#

i'd like you to be my mentor in the coding world. i'm steve from ghana

upper hare
#

Ok if you're gonna be a creep I'm out

steel mulch
#

no please

#

i started laravel recently

#

i want someone to be coaching me and watching my project

#

i realize there's more in laravel i don't know...i heard something new that can be used to replace js is called livewire

upper hare
#

Ok so? Then pay someone to be your mentor? You're expecting me to randomly assist you and help you in my spare time. That ain't how the world works