2016-07-13 59 views
0

我有兩種方法顯示和指數 我對指數方法的項目列表,當用戶點擊它帶她到包含另一個頁面加載顯示方法的內容laravel上的索引方法一些屬於該ID的數據。而不是這樣做我想用jQuery來實現這一點,使數據加載在同一頁面上。我有我的看法index.blade.php下面,請我如何在laravel實現這一如何使用jQuery

 @foreach ($categories as $category) 

     <div class="body"> 
     <h4><a style="text-decoration: none; " href="{{ URL::route('category.show', $category->id) }}">{{$category->name}}</a></h4> 

     </div> 
     @endforeach 

    <?php 
    namespace App\Http\Controllers; 
    use Illuminate\Http\Request; 
    use illuminate\HttpResponse; 
    use App\Http\Requests\todolistRequest; 
    use App\Http\Requests\CreateCategoryRequest; 
    use App\Http\Requests; 
    use App\Companylist; 
    use App\Category; 
    use Illuminate\Support\Facades\DB; 
    class CategoryController extends Controller 
    { 

public function create(){ 
    return view('category.create'); 
} 

public function index(){ 
    $categories=Category::all(); 
    return view('category.index',compact('categories')); 
} 
public function store(CreateCategoryRequest $request){ 
    $category = new Category($request->all()); 
    $category->save(); 

     return \Redirect::route('category.create')->with('message',  'Your list has been created!'); 
} 
     public function show($id) 
     { 
     $category = Category::findOrFail($id)->companylist()->get(); 
     $cat=Category::findOrFail($id); 
    // this my route 
    Route::resource('category','CategoryController'); 

    return view('category.show')->with('category',  $category)->with('cat',$cat); 
} 


// 
} 
+0

顯示你的控制器代碼和路線 –

+0

AV更新闕@ ARIF MAHMUD RANA –

+0

阿里夫,您能有所幫助,AV更新我的AV做到了這一點利用正常程序PHP的問題 –

回答

0

要顯示的索引頁詳細數據,而無需頁面清爽,你應該使用ajax,在AJAX返回數據並顯示它在索引頁(即下每個列表)

在阿賈克斯,你必須通過ID,並根據相應的數據ID的回報。

希望它可以幫助

+0

,所以我需要一個laravel這樣做的方式。 –