2017-07-13 5 views
0

Ich arbeite an einem Projekt und Gesicht mit einem Problem, und ich konnte keine spezifische Lösung im Internet Ich möchte Daten Bootstrap Modal in der Datenbank speichern, aber wenn ich speichern drücken Taste, um es mir MethodNotAllowedHttpException in Zeile 251 geben dieseSubmit Formular innerhalb Bootstrap Modal in Laravel 5.4

mein hTML-Code ist

<div class="container"> 
 
    <div class="row"> 
 
    <div class="col-md-8 col-md-offset-2"> 
 
     <h3>معلومات عمومی سیستم</h3> 
 
     <ul class="nav nav-tabs"> 
 
      <li class="active"><a data-toggle="tab" href="#home">دونر ها</a></li> 
 
      <li><a data-toggle="tab" href="#menu1">ولایت ها</a></li> 
 
      <li><a data-toggle="tab" href="#menu2">ولسوالی ها</a></li> 
 
     </ul> 
 

 
     <div class="tab-content"> 
 
      <div id="home" class="tab-pane fade in active"> 
 
       <button class="btn btn-success" data-toggle="modal" data-target="#myModal"><strong>ثبت دونر جدید </strong><i class="fa fa-plus"></i></button> 
 
       
 
     </div> 
 

 
     </div> 
 
    </div> 
 
</div> 
 

 

 
<!-- Modal --> 
 
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" 
 
    aria-labelledby="myModalLabel" aria-hidden="true"> 
 
    <div class="modal-dialog"> 
 
     <div class="modal-content"> 
 
      <!-- Modal Header --> 
 
      <div class="modal-header" style="color: #1abc9c;"> 
 
       <button type="button" class="close" 
 
         data-dismiss="modal"> 
 
        <span aria-hidden="true">&times;</span> 
 
        <span class="sr-only">Close</span> 
 
       </button> 
 
       <h3 class="modal-title" style="color: white">ثبت دونر جدید به سیستم</h3> 
 
      </div> 
 

 
      <!-- Modal Body --> 
 
      <div class="modal-body"> 
 

 
       <form class="form-horizontal" role="form" id="form-direction" method="post" action="{{action('\App\Http\Controllers\[email protected]')}}"> 
 
        {{csrf_field()}} 
 
        <div class="form-group"> 
 
         <label class="col-sm-2 control-label" for="name">نام دونر</label> 
 
         <div class="col-sm-10"> 
 
          <input type="text" class="form-control" name="name" placeholder="نام دونر"/> 
 
         </div> 
 
        </div> 
 

 
        <div class="form-group"> 
 
         <label class="col-sm-2 control-label" for="description" >معلومات راجع به دونر</label> 
 
         <div class="col-sm-10"> 
 
          <textarea class="form-control" name="description" placeholder="معلومات راجع به دونر"> </textarea> 
 

 
         </div> 
 
        </div> 
 

 
        <div class="form-group"> 
 
         <label class="col-sm-2 control-label" for="phone" >شماره تماس</label> 
 
         <div class="col-sm-10"> 
 
          <input type="text" class="form-control" name="phone" placeholder="شماره تماس"/> 
 
         </div> 
 
        </div> 
 

 
        <div class="form-group"> 
 
         <label class="col-sm-2 control-label" for="email" >ایمیل آدرس</label> 
 
         <div class="col-sm-10"> 
 
          <input type="email" class="form-control" name="email" placeholder="ایمیل آدرس"/> 
 
         </div> 
 
        </div> 
 
        <br> 
 

 
        <button type="submit" class="btn btn-primary lead" id="mysaveButton">ثبت</button> 
 

 

 
       </form> 
 

 
      </div> 
 

 
     </div> 
 
    </div> 
 
</div>
dies mein ajax-Code

ist

dies ist mein Weg

Route::get('donors','[email protected]');

aber ich bin mir nicht sicher über deren Korrektheit

und dies ist mein Controller

alles funktioniert gut, aber wenn ich die Taste, um es speichern schlagen sagt (1/1) MethodNotAllowedHttpException in RouteCollection.php (Linie 251) jeder Körper eine Idee hat Ihre Hilfe

wird zu schätzen wissen

Antwort

0

viel falsch mit diesem gibt es ...

Werfen Sie einen Blick auf Ihre <form> (speziell die Attribute im Anhang):

<form 
    class="form-horizontal" 
    role="form" 
    id="form-direction" 
    method="post" 
    action="{{action('\App\Http\Controllers\[email protected]')}}"> 

In Ihrem $("#mysaveButton").click(function(e){ ... }) Methode, sind Sie

Aufruf
... 
method: $form.attr('post'), 
url: $form.attr('\App\Http\Controllers\[email protected]'), 

welche beide undefined zurückkehren, da sie auf Ihrem <form> Element nicht attributes sind.

Sie verwenden sollten

... 
method: $form.attr('method'), 
url: $form.attr('action'), 
+0

ich das getan habe, aber es hat das Problem nicht lösen –

+0

Haben Sie Ihr 'Routes.php' Datei eine' Post' Methode zu ermöglichen, aktualisieren? Sie haben derzeit 'Route :: get ('Spender', 'DonorController @ store');', was offensichtlich nicht 'Route :: post (...) ist;' –

+0

ja, ich habe Route :: get() geändert route :: post() –

Verwandte Themen