I'm sending _csrf token in form even in ajax post but still i am getting #400 unable to verify data submission in yii2. I don't want to use the following code to avoide this issue:
public function beforeAction($action)
{
$this->enableCsrfValidation = false;
eturn parent::beforeAction($action);
}
This is not the permanent solution because applying this coded will breach the security here's my js Code.
$(document.body).on('submit','form#send-resource-form',function(e) {
var form = $(this);
$.ajax({ url: form.attr('action'),
type: 'post',
data: form.serialize(),
dataType: 'json',
beforeSend: function(){
// Handle the beforeSend event showLoader();
},
})
.done(function( response ) {
removeLoader();
if(response.status==1) {
mytargeted code.
}
})
});
here's my console headers and response
please any one know how to resolve this issue that would be a great help
Thanks