Home > Mobile >  Getting 404 Not Found in Laravel AJAX Request
Getting 404 Not Found in Laravel AJAX Request

Time:05-26

In my Laravel Projects, I want to pass data from blade to my controller using Ajax.

But I am getting error

404 | Not Found

ajax

var pi_id = $(this).attr('href');    
$.ajax({
        url: "{{ url('purchase-invoice-detail') }}",
        type: "get",
        data: {
            'id': pi_id
        },
        success: function(response){ // What to do if we succeed                
                alert('ok'); 
        },
        error: function(response){
            alert('Error' response);
        }
    });

route

Route::get('purchase-invoice-detail/{id}', 'PurchaseController@purchase_invoice_detail')->middleware('auth');

controller

public function purchase_invoice_detail($id)
{
    return 1;
}

Can't find the problem.

Anybody Help Please ?

CodePudding user response:

Please try this code

"{{ url('purchase-invoice-detail') }}"    '/'   pi_id
  • Related