Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Nov 27th, 2012  |  syntax: PHP  |  size: 0.70 KB  |  views: 371  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <?php
  2. namespace D\FormBundle\Controller;
  3.  
  4. use Symfony\Bundle\FrameworkBundle\Controller\Controller;
  5. use Symfony\Component\HttpFoundation\Response;
  6.  
  7. class MyAjaxController extends Controller
  8. {
  9.     public function indexAction()
  10.     {    
  11.         return $this->render('DFormBundle:Default:form.html.twig');
  12.     }
  13.    
  14.     public function updateDataAction(){
  15.          $request = $this->get('request');    
  16.          $data1 = $request->query->get('country');
  17.      
  18.  
  19.         //handle data
  20.  
  21.         //prepare the response, e.g.
  22.         $response = array("code" => 100, "success" => true);
  23.         //you can return result as JSON
  24.         return new Response(json_encode($response));
  25.     }  
  26. }