使用Laravel的Ajax POST错误

I want to submit a form of checkboxes that represent the interests of an user. When clicking a checkbox, the value of the checked interest will be sent to the database "Followers" table and the user will begin following that interest. I couldn't find a way to have one form submit multiple rows, so i decided to make each checkbox a different form and use Ajax to send the information as the user goes through the form. However, When i attempt to make a POST using Ajax I get POST http://localhost/interest net::ERR_CONNECTION_REFUSED. or ERR 500. Can someone help me? I don't understand where i'm messing up. here is my code:

i have the meta tag

<meta name="_token" content="{{ csrf_token() }}"/>

html:

{!! Form::open(array('id'=> 'form2')) !!}
                                <div class = "form-group">
                                    <div class="col-md-6">
                                        {!! Form::label('title','Title:', ['class' => 'col-md-4 control-label']) !!}
                                        {!! Form::checkbox('interest_id', '2', false, ['class' => 'formclick']) !!}
                                    </div>
                                </div>
                        <input id = "submit" type="button" value="Click Me!"  />
                                {!! Form::close() !!}

JS:

 var base_url = 'http://localhost';

$('#submit').click(function(){
   var interest = {
       interest_id : $('.formclick').val()
   }
$.ajaxSetup({
            headers: { 'X-CSRF-Token' : $('meta[name=_token]').attr('content') }
        });
$.ajax({
    type: 'POST',
    url: base_url+'/interest',
    data: interest,
    dataType: 'JSON',
    success: function() {
       alert('new interest');
    }
});

});

InterestController:

 public function store(InterestRequest $interest)
{
    $interest = new Follower(array(
        'user_id' => $interest->get('interest_id'),
        'follower_id'  => Auth::id()
    ));

    $interest->save();
}
  1. Don't use the same variable name for an parameter and a local scope variable.
  2. Are you using nginx or apache?
  3. Have you setup your .htaccess file right?
  4. What do you see when you go to http://localhost/interest/public
  5. Enable the Laravel debug mode, there you have much more information which can be of help to you and us.

You should use proper path of URL to ajax call.

instead of use: var base_url = 'http://localhost';

use: var base_url = '{{ url() }}';

It will resolve your issue