mardi 24 mai 2022

MethodNotAllowedHttpException on POST, giving on above 500 grid item

I am getting data on post method and converting it on excel and downloading it. But for grid item more then 500 it is giving MethodNotAllowedHttpException in RouteCollection.php line 255

Here is my code

$("#Exceldownload_jobAlloctn").click(function(){
    var getrowdata = $('#deliverylocation_grid_for_starhub').jqxGrid('getrows');
    var getrowdata = JSON.stringify(getrowdata);

    if($('#deliverylocation_grid_for_starhub').jqxGrid('getrows').length == 0)
                {
                    callnotify_alert("Error","No Data to Export",'danger');
                    return false;
                }
    else{
   
    //json.stringfy();
  //  console.log(tickets_jqxgrid_rows);
        $.ajax({
            headers: {
            'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
            },
            url: "/ExportStarhubJoballocationdata",
            dataType: 'text',
            type: "POST",
           // cache:false,
           processData: true,
        //    contentType: true,
            data: {"grid_data":getrowdata },
            error: function (error) {

                   console.log(error);
            },
            success: function (data) {
                console.log(data);
                
               // excel_nm= data;
                var excel_nm= data;
                var link1 = document.createElement("a");
                document.body.appendChild(link1);
                link1.download = data;
                link1.title = data;
                link1.setAttribute("type", "hidden");
                link1.setAttribute("download", data);
                 var url=$("#excelfile_url").val();
                link1.href = url+excel_nm; 
                
                link1.click();
                document.body.removeChild(link1);
                }

        });
    }
    
    });
```````````````````

Here is controller code

``````````````````````
public function ExportStarhubJoballocationdata(Request $request)
        {
          try{
          // return $request->grid_data;
            $decoded_request=json_decode($request->grid_data,true);
            //return count($decoded_request);
            //if(!empty($decoded_request))
            //{
                //return $decoded_request;
              $html = "";
              $html .='<table border="1"><tr>';
              $html .='<th>Sr. No</th>';
              $html .='<th>Job Name</th>';
              $html .='<th>RE Name</th>';
              $html .='<th>Star Hub</th>';
              $html .='<th>City</th>';
              $html .='<th>Element Name</th>';
              $html .='<th> Date Of Dispatch</th>';
              $html .='<th>Expected Date Of Delivery</th>';
              $html .='<th>No. of boxses</th>';
              $html .='<th>No. Quantity</th>';
              $html .='<th>Network</th>';
              $html .='</tr>';
              $sr_no=1;
              foreach($decoded_request as $res)
              {
                
                $html .='<tr>';
                $html .='<td>'.$sr_no.'</td>';
                $html .='<td>'.$res['ticketname'].'</td>';
                $html .='<td>'.$res['RE_fullname'].'</td>';
                $html .='<td>'.$res['hub_name'].'</td>';
                $html .='<td>'.$res['city_nm'].'</td>';
                $html .='<td>'.$res['elementname'].'</td>';
                $html .='<td>'.$res['m_delivery_date'].'</td>';
                $html .='<td>'.$res['m_expected_date_delivery'].'</td>';
                $html .='<td>'.$res['m_box'].'</td>';
                $html .='<td>'.$res['m_total_qty'].'</td>';
                $html .='<td>'.$res['f_network_nm'].'</td>';
               
                $sr_no++;
                //return (string)$html;
                }
            //}
                $html .='</table>';
                 //echo $html;exit;
                
                $data=$html;
              //  return $data;
                $filename = "StarhubJoballocation".date("Y-m-d_H:i:s").".xls";
                $file= Config::get('constant.excel_path').$filename;
                
                $file_open=fopen($file, "w");
                chmod($file,0777);
                if(fwrite($file_open, $data)){}
                else {echo "wrong";}
                fclose($file_open);
                echo $filename;exit;
            
          } 
            
          catch (\Exception $e) {
            return response()->json([
            'status' => 500,
            'message'=>'Something Went Wrong!'.$e->getMessage()
            ]);
            }
        }

Here is route web.php

Route::post("ExportStarhubJoballocationdata",'TicketDPController@ExportStarhubJoballocationdata');

Before it use to download properly now from few days it is happeing, No clue whats the problem tried increasing memory size and all but no luck.

Any help would be appreciated.

Thanks In advance!!!



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/guEP0Ob
via IFTTT

Aucun commentaire:

Enregistrer un commentaire