Unable to pass ajax to controller function
<p>I am trying to update my database using ajax in laravel. When i click the button (toggle button) it should update the database enable column from 1 to 0.</p>

<p>Here is the script written in the view</p>

<pre><code>$(".toggle-btn").change(function() {
    var id = $(this).attr('name'); // $(this) refers to button that was clicked

    $.ajax({
        url: '/adminpanel/dviulaan/stt',
        method: "post",
        data: {'id' : id} ,
        dataType: "json",

      });
});
</code></pre>

<p>Here is my route</p>

<pre><code>    Route::post('adminpanel/dviulaan/stt', 'AdminDvAnnouncement@status');
</code></pre>

<p>And here is the controller function</p>

<pre><code>public function status()
{
    $id = Input::all();

 if (Request::ajax()) {
    DvAnnouncement::where('announcement_id', $id)-&gt;update(
        [
            'enable' =&gt; '0',
            'user_updated' =&gt; Auth::user()-&gt;id,
            'updated_at' =&gt; new DateTime,
        ]);
}

        $response = array(
            'status' =&gt; 'success',
            'msg' =&gt; 'Option created successfully',
        );

        return Response::json( $response );

}
</code></pre>

<p>When i click the button it shows the following error in the consol</p>

<pre><code>POST http://localhost/adminpanel/dviulaan/stt 500 (Internal Server Error)
</code></pre>

<p>Please help me to find the error.</p>

<p>I have even changed the controller method as below</p>

<pre><code>public function status(Request $request)
    {
        $id = Input::get('id');

     if (Request::ajax()) {
        DvAnnouncement::where('announcement_id', $id)-&gt;update(
            [
                'enable' =&gt; '0',
                'user_updated' =&gt; Auth::user()-&gt;id,
                'updated_at' =&gt; new DateTime,
            ]);
    }

            $response = array(
                'status' =&gt; 'success',
                'msg' =&gt; 'Option created successfully',
            );

            return Response::json( $response );

    }
</code></pre>