without select category not show subcategory

后端 未结 2 1438
独厮守ぢ
独厮守ぢ 2021-01-28 00:38

This is create.blade.php file. In this include css and js file too.. Html code and ajax code view file

2条回答
  •  长发绾君心
    2021-01-28 01:05

    The jquery append code looks like it is correct. I think the problem may be in your routing.

    You've got

    url:"{{url('create')}}?category_id="+categoryID,
    

    as a GET request called through the Laravel method url(). It might help if you use url() here in the way you've got the route setup in web.php, which would use the full url path:

    url:"{{url('post/create/')}}"+categoryID,
    

    This lets the url() function add the parameter. However, it might also help to account for the incoming parameter on your routes file if it is a GET request (and add $category_id to the controller method):

    Route::get('post/create/{id}', 'PostController@create')
    

    I would probably make a separate function just to get the subcategories - then make your ajax call to that function and just pull the subcategories. A little cleaner.

    But I think your problem may be in the routing and perhaps some of the above will help you.

提交回复
热议问题