mardi 6 février 2018

404 not found in Laravel 5

I am calling ajax on change, I don't know it throws me 404 error. Where I am missing?

Here is my Jquery Code

$('#group_id').change(function(){
        var group_id = this.value;
        getSubCategory(group_id);
    });

function getSubCategory(id)
    {
        var subcategories_url = "";   
        console.log(subcategories_url);

        $.ajax({

            url: subcategories_url,
            type: 'POST',
            data: {'id': id},            
            success: function (resp) {
                $this.removeAttr('disabled');
                data = JSON.parse(resp);       
                alert(data);         
                if(data.status == 'failed' || data.status == false){
                    $('.alert-danger').show();
                    $('.alert-danger').html(data.message);
                } else {                    
                    $('.alert-success').show();
                    $('.alert-success').html(data.message);                    
                }
            },
            error: function (data) {                
                $('.alert-danger').show();
                $('.alert-danger span.show_error_msg').html(data.message);
            }
        });

    }

When I call through ajax function, it throws me 404 not found error, I don't know where I am missing. Can anyone help me out.

Here is my routes file:

Route::post('/groups/fetchsubcategory','admin\GroupsController@getSubCategory'); 



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire