I can't download my XLS file via Ajax

```
function downloadFile(response) {
        var blob = new Blob([response], {type: 'application/vnd.ms-excel'})
        var url = URL.createObjectURL(blob);
        location.assign(url);
    }

    $('#export').click(function () {
        $.ajax({
            type: 'POST',
            url : 'factures/engagements/selected/export',
            headers: {'X-CSRF-TOKEN': '{{ csrf_token() }}' },
            dataType: "json",
            data : {
                checkboxes : checkboxValues
            }
        }).done(downloadFile);
    });

```

my controller : 

```
public function exportFacturesEngagementSelected(Request $request){

    $checkboxes = $request->input('checkboxes');

    $collection = collect($checkboxes);

    $engagements = EngagementOrder::whereIn('id' , $collection)->get();

    $date = Carbon::now('Europe/Paris')->format('d-m-Y H:i:s');

    $output = Excel::create('factures_engagements' . $date. '', function($excel) use ($engagements) {
        $excel->sheet('Excel', function($sheet) use ($engagements) {
            $sheet->loadView('engagements.exportExcelSelected')->with("engagements", $engagements);
        });
    })->export('xls');

    return $output;
}

```

I only get the output preview of the file in my console network, but nothing happens in my browser; no file is downloaded. What am I doing wrong? 

UPDATE @matticustard solution : 

my checkboxValues is a json for exemple the result is 

> 
> {920: "920", 927: "927", 931: "931", 939: "939"}
> 
> 
> 

when i console log query i get : 

> 
> undefinedcheckboxes=920&checkboxes=927&checkboxes=931&checkboxes=939&
> 
> 
> 

When i try to get the values to my controller i made a $request->all() and i get : 

```
array:2 [
  "undefinedcheckboxes" => "920"
  "checkboxes" => "939"
]

```

why i get undefinedcheckboxes and why i don't get the other ids ?