php - return blade after execute ajax

i??m traying to load @include() blade in other blade in laravel after response ok in ajax. I??m doing a statistics in tab pane and i need send data to my controller, for this i??m doing ajax i have this ajax:

$("#createStatistcs").on('click', function(){
        let fromDate = $("#fromDate").val();
        let toDate = $("#toDate").val();
        let token = $('meta[name=csrf-token]').attr('content');

        $.ajax({
            type: 'GET',
            url: "{{ route('admin.llamadas.estadisticas') }}",
            data: { 'fromDate': fromDate, 'toDate': toDate },
            success: function(response){
                
            },
            error: function(xhr){
                alert(xhr.responseText);
            }
        });
    })

and i have this in my controller:

public function index(Request $request)
    {
        $estadosLlamadas = EstadoLlamada::orderBy('desc')->get();

        if(isset($request->fromDate) && isset($request->toDate)){
            $fromDate = Carbon::parse($request->get('fromDate'));
            $toDate = Carbon::parse($request->get('toDate'));

            $fromDate = $fromDate->format('Y-m-d');
            $toDate = $toDate->format('Y-m-d');

        }else{
            $fromDate = new Carbon('first day of this month');
            $toDate = new Carbon('last day of this month');

            $fromDate = $fromDate->format('Y-m-d');
            $toDate = $toDate->format('Y-m-d');
        }

        $teleoperadoras = auth()->user()->whereIs('teleoperadora')->activos()->select(['id', 'nombre'])->orderBy('nombre', 'desc')->get();
        
        $array = [
            'toDate'   => $toDate,
            'fromDate' => $fromDate,
            'nombresEstados' => $estadosLlamadas->pluck('desc')->toArray(),
            'coloresEstados' => $estadosLlamadas->pluck('hex')->toArray()
        ];

        $query = Llamada::query()
            ->whereDate('llamada.created_at', '<=', $toDate)
            ->whereDate('llamada.created_at', '>=', $fromDate)
            ->whereIn('llamada.id_teleoperadora', $teleoperadoras->pluck('id'))
            ->join('users', 'llamada.id_teleoperadora', '=', 'users.id')->latest('llamada.created_at')->get();

        foreach($teleoperadoras as $teleoperadora) {
            $array['teleoperadoras'][] = $teleoperadora->nombre;
            $array['id_teleoperadoras'][] = $teleoperadora->id;
            $array[$teleoperadora->id]['resultados'] = [];
            $array['llamadas'][] = $query->where('id_teleoperadora', $teleoperadora->id)->count();

            $array['llamadasTodo'][$teleoperadora->id] = $query->where('id_teleoperadora', $teleoperadora->id);

            foreach($estadosLlamadas as $estado) {
                $array[$teleoperadora->id]['resultados'][] = $query->where('id_teleoperadora', $teleoperadora->id)->where('id_estado', $estado->id)->count();
            }
        }

        $array['nllamadas'] = $query->count();
        $roleUser = auth()->user()->getRoles()->first();

        $view = view('admin.llamadas.filtrado', [
                    'datos' => $array, 'estados' => $estadosLlamadas,
                    'teleoperadoras' => $teleoperadoras, 'roleUser' => $roleUser,
                ])->render();
        echo response()->json(['html'=>$view]);
    }

this function return all data i need. But i want that don??t reload my page and generate graphic in this view.

i??m traying this, don??t return error, but return nothing. I??m reading in google and many people say that use ->render() but i can??t show result

Thanks for help me and readme

Answer

Solution:

If you have a div in your template where you want this blade view to be displayed, you can do:

$("#createStatistcs").on('click', function(){
        let fromDate = $("#fromDate").val();
        let toDate = $("#toDate").val();
        let token = $('meta[name=csrf-token]').attr('content');

        $.ajax({
            type: 'GET',
            url: "{{ route('admin.llamadas.estadisticas') }}",
            data: { 'fromDate': fromDate, 'toDate': toDate },
            success: function(response){
                $('your-element').html(response.html);
            },
            error: function(xhr){
                alert(xhr.responseText);
            }
        });
    })

Source