Hi, I'm using laravel 5 and I'm trying to post some data via ajax but I can't figure this out...
 
I have the following route:

Route::post('stream/post-comment', ['as' => 'stream.post.comment', 'uses' => 'social\streamController@postComment']);

The following HTML form:
{!! Form::open(['route' => ['stream.post.comment'], 'method' => 'POST', 'class' => 'ajaxForm']) !!}
    {!! Form::hidden('stream_id', $stream['id']) !!}
    {!! Form::text('commentText', null, ['class' => 'form-control']) !!}
    {!! Form::text('post', ['class' => 'btn btn-primary postComment']) !!} 
{!! Form::close() !!}


This is my jquery:
$(document).ready(function(){
    $('.postComment').click(function(e){
        e.preventDefault();
        $.ajax({
            url: 'stream/post-comment',
            type: 'post',
            data: form.serialize(),
            dataType: 'json',
            success: function(){
                $(form).find('input[name="commentText"]').val('');
            },
            error: function(){
                //display some kind of error here
            }
        })
        return false;
    });
});

I'm a jquery beginner, so this code might have some problems...

And this is the method in my controller:



public function postComment(Request $req){
        if($req->ajax()) {
            if ( Session::token() !== Input::get( '_token' ) ) {
                return Response::json( array(
                'msg' => 'Unauthorized attempt to create setting'
               ));
            }
        streamComments::create([
            'stream_id' => Input::get('stream_id'),
            'comment' => Input::get('commentText'),
            'posted_by' => Auth::user()->id
        ]) ;
        $response = array(
            'status' => 'success',
            'msg' => 'Comment created successfully',
        );
        return Response::json( $response );
        }
    }

If I use Request::ajax() instead of $req->ajax() I get this error:

Non-static method Illuminate\Http\Request::ajax() should not be called statically, assuming $this from incompatible context

If I use print_r( Input::all() ) in the controller instead of the code above i get this:

Array ( [_token] => q07PK2JQ2adm3HUvlzNBVBvqEnGQkEkOtjeXnlUZ [stream_id] => 2 [commentText] => this is my message )

but I'm redirected to stream/post-comment...
What i'm missing or what i'm doing wrong?
 
Thank you!

Edit
-----------
Just found my problem and fixed the code.