Symfony Ajax Controller Handler, always fires jQuery error function

I am really new with Symfony framework I am just trying to implement a simple ajax example:


    pattern:  /data/user
    defaults: { _controller: DartDartBundle:Data:user }
        _method:  POST


namespace Dart\DartBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\JsonResponse;

class DataController extends Controller
    public function userAction(){      
        $content = array('success' => true, 'name' => 'luis');
        $response = new JsonResponse($content,200);
        $response->headers->set('Content-Type', 'application/json; Charset=UTF-8');
    return $response;

And the ajax call:

    type : 'GET',
    dataType: 'json',
    url : '',
    success : function(data){
    error: function (xhr, ajaxOptions, thrownError){   
        console.log("SOME ERROR OCURRED");

But it always fires the error function. I don't know why. I've try without specifying jston dataType and using Response instead of JsonResponse.

I don't know whats wrong.



Route is configured as POST - only

The Ajax request is a GET request

try to remove the requirement


Try to access the url directly in your browser to check if you configured the path right and you can access the controller.

The request is made from the same server but with a different domain. The request is not using any vhost or domain, its uses server's ip and the htdocs folder.

Symfony is placed in a folder which has a vhost alias and its accessed using a domain (i.e. The folder in the server is inside /DART root folder. So its ./DART/symfony....

The firebug info for either of the methods. For instance, for GET method:

Need Your Help

zoom an image on a coordinate using jquery on onclick

javascript jquery ajax

I want to zoom an JPEG image with predefined image coordinates using onclick function.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.