I'm a newbie in laravel. I want to add a product using ajax method but I'm getting this error, in the console: POST 404 NOT FOUND
. In the network, I'm getting this error message:
{message: "", exception: "Symfony\Component\HttpKernel\Exception\NotFoundHttpException",…}
exception: "Symfony\Component\HttpKernel\Exception\NotFoundHttpException"
file: "C:\Usersolan\Desktop\Laravel Tutorial\Fims\vendor\laravel\framework\src\Illuminate\Routing\RouteCollection.php"
line: 179
message: ""
trace: [{,…}, {,…}, {,…}, {,…}, {,…},…]
Here is my ajax code:
<script>
$(document).ready(function(){
// alert("working");
$("#btn").click(function(){
var prodName = $("#prodName").val();
var rate = $("#rate").val();
var beginningQuantity = $("#beginningQuantity").val();
var token = $("#token").val();
$.ajax({
type: "POST",
data: "prodName=" + prodName + "&rate=" + rate + "&beginningQuantity=" + beginningQuantity + "&_token" + token,
url: "<?php echo url('/saveProduct') ?>",
success: function(data){
console.log(data);
}
});
});
});
</script>
here's the line 179 codes
<input type="hidden" value="{{csrf_token()}}" id="token">
here's the controller code
public function saveProduct(Request $request){
return $request;
}
here's the route
Route::get('/adminIndex',"adminIndexController@count");
Route::get('/adminInventory',"adminInventoryController@count");