Monday, 30 October 2023

Laravel javascript Fetch method

 $(document).on('click', '.quick-view-btn', function() {

            const rowId = $(this).data('id');

            const url = `{{ url('administrator/Careers/applied-candidate/get-details/') }}/${rowId}`;

 

            getApplicationData(url).then((response) => {

             // Do it your code 

            });

 

            $("#quickViewModal").modal('show');

        });

 

 

        async function getApplicationData(url) {

            try {

                const response = await fetch(url, {

                    method: 'GET',

                    headers: {

                        'Content-type': 'application/json',

                    }

                });

                if (!response.ok) {

                    throw new Error(`Request failed with status: ${response.status}`);

                }

                return response.json();

            } catch (error) {

                throw error;

            }

        }

No comments:

Post a Comment

Laravel Export data to csv

 use Illuminate\Http\Response; // Define a function to export data to CSV function exportToCSV($exportData, $columns) {     $filename = ...