I would like to send Post Data to a Symfony Controller, but it doesn't work. When I send my data with AJAX, it is sending the POST data, but it is showing red link in the console with no error message or status.

Here is my Javascript code:

    function addprivate(){
        var form_data   = $('#private_tuition').serialize();
        var getTeamsUrl = Routing.generate('addprivatetuition',{id:form_data});
        $.ajax({
            type    : "post",
            url     : getTeamsUrl,
            data    : form_data,
            success : function(response){
                if(response){

                }else{

                }
            },
            error   : function(XMLHttpRequest, textStatus, errorThrown){
                $.notify('Error : Record not found !!',{"status":"danger","pos":"top-center"});
            }
        }); 
    }

Below is the form tag and js funxtion:

<form method="post" role="form" id='private_tuition' action="{{base_url}}/privatetutionpdf/" >
<button type="submit" class='btn btn-primary' onclick='addprivate()' name="btn-save"><strong>Generate PDF for client</strong></button>

Here is the PHP Symfony Controller method which received data:

namespace Suntec\Marcus\AssignmentBundle\Controller;
use Symfony\Component\HttpKernel\Bundle\Bundle;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Security\Core\SecurityContextInterface;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;

class DefaultController extends Controller
{
....
    /*****************************************************************/
    /**
    * @Route("/addprivatetuition", name="addprivatetuition", options={"expose"=true})
    * @Template()
    */
    public function addprivatetuitionAction(){

        return array();
        //return array();
    }
...

}

but it is showing red link in the console with no error message or status.

If you meant Google Chrome Console then can you check if there is any additional information in the Network tab? When a request fails even if the status code is not returned it should say something like (failed) and, by hovering, it should return a description of the error, like: (failed) net::ERR_BLOCKED_BY_CLIENT.

From this we should be able to understand if the request is actually sent to the server or if it is blocked by the browser. You can also check to the access & error logs of the web server to find if a request was received.

And: can you successfully send the request through a normal form?

I am generating a PDF on button plus (want) add record via ajax. In chrome, my request is going for PDF generation (now in a new tab) and it is doing successfully. Attached screenshot; Yes, it is sending the request successfully through a normal form.

Sorry, but it seems the attachment is not showing on your post. Once uploaded, in case of images, you have to choose how to display the attachment. Retry or, if possible, show us an online version of this page.