Submit Form within Bootstrap Modal - TokenMismatchException Error

Posted 1 year ago by almost_pitt

Hey guys,

I'm creating a form inside of a bootstrap modal. Here is the form:

<form action="{{ url('/post')}}" method="POST" id="my_form">
  {{ csrf_field() }}
  <input type="text" name="Comments" id="Comments">
  <button onclick="form_submit()">Submit</button>

and here is the javascript I'm using to post it:

<script type="text/javascript">
function form_submit() {

Unfortunately, when I submit, I get the following error:

(1/1) TokenMismatchException in VerifyCsrfToken.php (line 68)

I've also tried to insert a hidden field for the token:

<input type="hidden" name="_token" id="csrf-token" value="{{ Session::token() }}" />

Unfortunately, no luck.

Any idea how I can fix this?


Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.