title: How to display alert or info messages in Symfony2 after a server response without reloading the page
body: <p>I am building an admin application for opticians with Symfony2. When the admin adds a new customer to the database, my controller checks if the customer name is duplicate or not. I want to display a popup dialog that asks the user if he wants to add the new customer anyway or not. How can I implement this? Should I use Ajax? Here is a sample code from the controller I am using in this case :</p>
  
  <pre><code>public function nouveauAction(Request $request)
  {
      $form = $this-&gt;createFormBuilder()
          -&gt;add('nom','text')
          -&gt;add('tel','text', array('label' =&gt; 'Nº de téléphone', 'data' =&gt; '06'))
          -&gt;add('email','email', array('label' =&gt; 'E-mail', 'required' =&gt; false))
          -&gt;add('date','date', array('label' =&gt; 'Date d\'ajout', 'data' =&gt; new \DateTime()))
          -&gt;add('ajouter','submit')
          -&gt;getForm()
      ;
  
      $form-&gt;handleRequest($request);
  
      if ($form-&gt;isValid()){
  
          $client = new Client();
          $client-&gt;setNomClient($form["nom"]-&gt;getData());
          $client-&gt;setTelClient($form["tel"]-&gt;getData());
          $client-&gt;setEmailClient($form["email"]-&gt;getData());
          $client-&gt;setDateEditionClient($form["date"]-&gt;getData());
          //just for now (Later we'll retrieve the username from the session)
          $em = $this-&gt;getDoctrine()-&gt;getEntityManager();
          $user = (new Utilisateur)-&gt;rechercherParPseudo($em, 'admin');
          $client-&gt;setIdUtilisateur($user);
  
          $em = $this-&gt;getDoctrine()-&gt;getEntityManager();
  
          if($client-&gt;existe($em))
          {
              //I need a popup message here : The customer you are trying to add already exists""
          }
  
          else
          {
              $request = $this-&gt;container-&gt;get('request');
              if($client-&gt;existeNomDouble($em)) //If the customer name is duplicate
              {
                  //I need a popup message here with Yes/No buttons...
              }
              else
              {
                  //Writing to the database:
                  $em = $this-&gt;getDoctrine()-&gt;getEntityManager();
                  $client-&gt;ajouterClient($em);
  
                  //A notification to fade in here : "Customer successfully added"
              }
  
  
          }
  
      }
  
      return $this-&gt;render('ClientBundle:Client:nouveau.html.twig', array(
          'formAjouter' =&gt; $form-&gt;createView(),
      ));
  }
  </code></pre>