Answer the question
In order to leave comments, you need to log in
How to solve 419 error with laravel token?
All with the upcoming!
Help solve the problem with the token!
Here is the code:
<input class="qty-input" type="text" name="testid" value="1" id="count">
<div class="g-input"><input class="" type="text" name="test1" placeholder="Ваш email"></div>
<div class="g-input"><input type="text" name="test2" placeholder="+7 (900) 000-00-00"></div>
<div class="g-input"><textarea maxlength="500" name="message" placeholder="Оставьте комментарий к заказу или задайте интересующий вопрос" id="messagetest"></textarea></div>
<button id="sendOrdertest">Подтвердить отправку</button>
<script type="text/javascript">
$(document).ready(function() {
$('#sendOrdertest').click(function(){
var counttest = $('#testid').val();
var test1 = $('input[name="test1"]').val();
var test2 = $('input[name="test2"]').val();
var messagetest = $('#messagetest').val();
$.post('{{route('modal.izgotovleniye')}}', {counttest:counttest, test1:test1, test2:test2, messagetest:messagetest}, function(data){
alert('Тест сработал!')
});
});
});
</script>
Route::post('/modal/izgotovleniye/', '[email protected]')->name('modal.izgotovleniye');
public function modal(request $request){
Orders::insert(['tel' => $request->test1, 'email' => $request->test2, 'created_at' => date('Y-m-d H:i:s')]);
}
<meta name="csrf-token" content="{{ csrf_token() }}">
I tried to put in the scriptvar data = {"_token": $('meta[name="csrf-token"]').attr('content')};
But something didn't go according to plan, it didn't work. Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question