Laravel Controller HTML输出

时间:2019-01-09 15:26:34

标签: laravel laravel-5.7

我正在尝试从ajax请求输出html输出,如下所示:

public function fetchFiles(Request $request)
{

    $application_id = $request->get('application_id');
    $applicant_id = $request->get('applicant_id');


    $data = DB::table('applicant_attachments')
        ->where('applicant_id','=', $applicant_id)->where('application_id','=', $application_id)->get();

    $output = '<table border="2">';
    $myAction="viewDOC";

    foreach($data as $row)
    {
        $output .= '<tr><td><form name="view_attachie" id="view_attachie" class="row" action="'.$myAction .'" method="post">@csrf</td>   <td>' .$myToken .'</td>
                    <td><input type="hidden" name="myfile[]" id="myfile[]">'.$row->description .' </td><td><button id="btnViewDoc" class="btn btn-sm btn-primary"
                    onclick="frmViewDOC();">View The Attachment</button></td><td></form></td></tr>';


    }
    $output .='</table>';
    echo $output;
}

ajax返回输出,但是当我单击刀片中的按钮时,令牌不起作用,并且显示@csrf而不是进行渲染。我该如何解决? 请帮帮我。

0 个答案:

没有答案