0

i am using jquery ajax in laravel for reading some data from database. i wrote this code and the $ajax() part not working! but every thing before that working great. what is wrong ?

$('#file_type').on('change',function(){
        $value=$(this).val();
        $.ajax({
            type : 'get',
            url : '{{URL::to('fileType.categories')}}',
            data:{'file_type':$value},
            success:function(data){
                alert('ooooops1');
                $('#file_type_cats').html(data);
            }
        });
    });
$.ajaxSetup({ headers: { 'csrftoken' : '{{ csrf_token() }}' } });

my routes are OK. i'm using select element to run ajax. if i write alert($value); before $.ajax() it works good. but ajax not working.

update: solved i was using the route name which is wrong. i must use the url intself not the name!.

4

1 Answer 1

1

Use the route helper if you want to use the route name:

{{ route('fileType.categories') }}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.