我試圖讓一個類別的基礎上的子類別中laravel 5.1,但首先這是給我「500內部服務器錯誤」的錯誤,但我有404未找到錯誤阿賈克斯Laravel 5.1
RewriteBase/
在我的.htaccess文件中,並且它給我錯誤'未找到404錯誤'。我使用虛擬主機和自動包含'csrf token'的Form Facade,所以我認爲這不是'csrf'令牌問題的問題。任何人都可以在這方面幫助嗎?
這是我的行程的文件:
// Admins Tasks
路線::組([ '中間件'=> '管理員'],函數(){
//Route::resource('/showcategoreis/{$id}', '[email protected]');
Route::get('/ajax-subcat/{id}', function(){
return "mkj";
$cat_id = Input::get('cat_id');
$subcategories = Subcategory::where('category_id', '=', $cat_id)->get();
return Response::json($subcategories);
});
Route::resource('/admin', 'Admin\AdminController');
Route::resource('/user', 'UserController');
Route::resource('/province', 'ProvinceController');
Route::resource('/city', 'CityController');
Route::resource('/category', 'CategoryController');
Route::resource('/subcategory', 'SubcategoryController');
Route::resource('/brand', 'BrandController');
Route::resource('/model', 'BModelController');
});
view.blade文件
@extends('admin.layout.master')
@section('title')
Add New Brand
@endsection
@section('content')
<div class="col-md-6 col-md-offset-3">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Add New Brand</h3>
</div>
<div class="panel-body">
{!! Form::open(['files'=>true, 'url' => '']) !!}
<div class="form-group">
{!! Form::label('brand', 'Brand Title') !!}
{!! Form::text('brand', null, ['class' => 'form-control']) !!}
<small class="text-danger">{{ $errors->first('brand') }}</small>
</div> {{-- brand --}}
<div class="form-group">
{!! Form::label('category_id', 'Category') !!}
{!! Form::select('category_id', $categories, $options = ['id'=>'category_id', 'class' => 'form-control']) !!}
<small class="text-danger">{{ $errors->first('category_id') }}</small>
</div> {{-- category_id --}}
<div class="form-group">
{{-- {!! Form::label('subcategory_id', 'Subcategory') !!} --}}
{{-- {!! Form::select('subcategory_id', $subcategories, $options = [ 'id'=>'subcategory', 'class' => 'form-control']) !!} --}}
{{-- <small class="text-danger">{{ $errors->first('subcategory_id') }}</small> --}}
<label for="">Subcategories</label>
<select name="subcategory" id="subcategory">
<option value=""></option>
</select>
</div> {{-- subcategory_id --}}
<hr>
<div class="btn-group pull-left">
{!! Form::submit('Add', ['class' => 'btn btn-primary', 'style'=>'margin-right:5px']) !!}
{!! HTML::link(action('[email protected]'), 'Cancel', ['class' => 'btn btn-warning']) !!}
</div>
{!! Form::close() !!}
</div>
</div>
</div>
@endsection
{{ - JS的AJAX - }}
<script type="text/javascript">
$(document).ready(function(){
$('#category_id').on('change', function(e){
console.log(e);
var cat_id = e.target.value;
//Ajax
$.ajax({
type: 'get',
// url: 'http://localhost/property-project/public/index.php/ajax-subcat?cat_id'+cat_id,
// url: 'http://www.laravelproperty.com/brand/create/ajax-subcat?cat_id='+cat_id,
url: '/ajax-subcat?cat_id='+cat_id,
scuccess: function(data){
console.log(data);
}
});
// $.get('/ajax-subcat?cat_id='+cat_id, function(data) {
// //scuccess data
// console.log(data);
// });
});
});
</script>
.htaccess文件
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule^index.php [L]
</IfModule>
虛擬主機文件
<VirtualHost *:80>
ServerAdmin [email protected]
ServerName laravelproperty.com
ServerAlias www.laravelproperty.com
DocumentRoot /var/www/property-project/public
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory /var/www/property-project/public/>
AllowOverride All
</Directory>
</VirtualHost>
我已刪除了」的.htaccess',仍然得到錯誤,這是錯誤堆棧的變化:
Sorry, the page you are looking for could not be found.
1/1
NotFoundHttpException in RouteCollection.php line 143:
in RouteCollection.php line 143
at RouteCollection->match(object(Request)) in Router.php line 746
at Router->findRoute(object(Request)) in Router.php line 655
at Router->dispatchToRoute(object(Request)) in Router.php line 631
at Router->dispatch(object(Request)) in Kernel.php line 236
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 139
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in VerifyCsrfToken.php line 50
at VerifyCsrfToken->handle(object(Request), object(Closure))
at call_user_func_array(array(object(VerifyCsrfToken), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in ShareErrorsFromSession.php line 54
at ShareErrorsFromSession->handle(object(Request), object(Closure))
at call_user_func_array(array(object(ShareErrorsFromSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in StartSession.php line 62
at StartSession->handle(object(Request), object(Closure))
at call_user_func_array(array(object(StartSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in AddQueuedCookiesToResponse.php line 37
at AddQueuedCookiesToResponse->handle(object(Request), object(Closure))
at call_user_func_array(array(object(AddQueuedCookiesToResponse), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in EncryptCookies.php line 59
at EncryptCookies->handle(object(Request), object(Closure))
at call_user_func_array(array(object(EncryptCookies), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in CheckForMaintenanceMode.php line 42
at CheckForMaintenanceMode->handle(object(Request), object(Closure))
at call_user_func_array(array(object(CheckForMaintenanceMode), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
at Pipeline->then(object(Closure)) in Kernel.php line 122
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 87
at Kernel->handle(object(Request)) in index.php line 54
我不認爲你需要修改.htaccess文件。刪除對.htaccess文件的修改,運行你的代碼,如果你得到500內部服務器錯誤,然後複製錯誤堆棧跟蹤並粘貼在這裏! – Ymartin
你好Ymartin,謝謝你的迴應。正如你所建議的,我已經刪除了'.htacecss'中的修改並仍然出現錯誤,但我仍然收到錯誤信息,並且已將其粘貼到底部的問題中。你能幫我這方面嗎? – MKJ