How to add meta headers to dhtmlx ajax helper requests

Hi,

I am not sure if this falls into dhtmlx form but its related to
docs.dhtmlx.com/api__refs__dhtmlxajax.html

What I’m trying to achieve is to add the following csrf header to ajax requests
laravel.com/docs/5.0/routing#csrf-protection

In jquery, the example shown in the website works.
How do I make sure the meta headers are added in the window.dhx4.ajax.post() requests ??

Check the query API

docs.dhtmlx.com/api__dhtmlxajax_query.html

dhx4.ajax.query({ method:"POST", url:"some.php", headers:{ "some-csrf":"value" } });

Brilliant. Thank you

Dear sir,

I follow you example, but I can not get value, can you tell me where i miss.
–js file–
dhx4.ajax.query({
method:“POST”,
url:"{{route(‘system.gtreeDelete’)}}",
data: “id1=”+treeId,
headers:{
“X-CSRF-TOKEN”:"<?php echo csrf_token(); ?>"
}
});

–controller–

public function gtreeDelete(Request $request){

    $id1 = 0;

    $id1 = $request->input('id1');
    $result = DB::table('USRAB')
            ->where('AB001', $id1)
            ->update([
                'AB020' => 0
            ]);
    return 'success';

}

– SQL result–
update [USRAB] set [AB020] = ‘0’ where [AB001] is null

thank you a lot

Hi,

Try to use

headers:{ "X-CSRF-TOKEN":"<?php echo csrf_token(); ?>", "Content-Type": "application/x-www-form-urlencoded" }

thank you , sir