php - using ajax in laravel 5.4 ERROR : Not found -
why have error not found in network console web browser?
here i've done :
my ajax:
 function getproducts(category_id) {     $("#product-list").empty();     $.ajax({         url:'{{url::to('home.products')}}/"+ category_id',         type:"get",         datatype: "json",             success: function(data) {              }     }); } my route:
route::get('/home/products', 'homecontroller@productsbycat')->name('home.products'); my controller:
public function productsbycat($category_id)      {         $products = db::table('products')         ->select('products.product_id','products.featured_img','products.product_name','products.description',                  'products.price','products.quantity')         ->join('products', 'categories.category_id', '=', 'products.category_id')         ->where('products.status', 'published')         ->where('products.category_id', $category_id)         ->get();          return $products;     } please me check code if there need change? or returning json file format in return $products ?
try in route
route::get('/home/products/{category_id}', 'homecontroller@productsbycat')->name('home.products'); and in ajax request try url this
url:'{{url::to("home.products")}}/'+ category_id', 
Comments
Post a Comment