2017-07-17 63 views
1

我正在使用Laravel框架。當我試圖檢查標題是否已經存在時,它會發出404錯誤。如何解決這個錯誤?Laravel遠程方法給404(Not Found)錯誤標題存在檢查

ServicesController.php 
Controller: 

public function checkEmail() 
    { 
     $service = Service::all()->where('title', Input::get('title'))->first(); 
     if ($service) { 
      return Response::json(Input::get('title').'is already taken'); 
     } else { 
      return Response::json(Input::get('title').'is available'); 
     } 
    } 

routes.php文件:

路線::獲得( 'checkEmail', 'ServicesController @ checkEmail');

視圖(create.blade.php):

$("#slider-form").validate({ 
    rules: { 
    title: { 
     required: true, 
     remote: { 
     url: "checkEmail", 
     type: "get", 
     } 

    }, 
    ar_title: { 
     required: true 
    } 
    }, 
    messages: { 
    title: { 
     required: "<font color='red'>Please Enter Service Name</font>", 
     remote: "<font color='red'>Service Already Exists</font>" 
    }, 
    ar_title: { 
     required: "<font color='red'>Please Enter Service Name in Arabic</font>" 
    } 
    }, 
    submitHandler: function(form) { 
    form.submit(); 
    } 
}); 
+0

在'url:「checkEmail」提供完整的網址,' –

+0

你的意思是網址:「www.domain.com/checkEmail」....! –

+0

打開你的網絡標籤,並檢查網址 –

回答

0

AS您的形式是這樣的

<form class="form-horizontal tasi-form" method="post" name="user-form" action="{{url('services/store')}}" id="slider-form" enctype="multipart/form-data"> 

在你的路由文件添加路由作爲

Route::post('services/store','[email protected]'); 

修改: -更改

<form class="form-horizontal tasi-form" method="post" name="user-form" action="services/store" 
     id="slider-form" enctype="multipart/form-data"> 
Route::post('services/store','[email protected]'); 

然後嘗試
它會爲你工作。

+0

我改變了,但它給404錯誤 –

+0

只是顯示你的表單動作代碼? \t \t action =「{{url('services/store')}}」id =「slider-」form =「form-horizo​​ntal tasi-form」method =「post」name =「user-form」 –

+0

< form「enctype =」multipart/form-data「> –

相關問題