This forum is in READ-ONLY mode.
You can look around, but if you want to ask a new question, please use Stack Overflow.

getJson request insert not-desired comment in my symfony app

Discussion relating to version 1.3.x and 1.4.x

getJson request insert not-desired comment in my symfony app

by jllavec » Thu Mar 12, 2015 1:25 pm


It worked fine in another server, but i have to migrate application to other server, and now, it doesn't work.

I have in my symfony project a call to a getter function, who sends a Json, and it works fine in the old server and sends a Json like that:

Code: Select all
"{"horario":["Lunes (libre)","Martes (libre)","Mi\u00e9rcoles (libre)","Jueves (libre)","Viernes (libre)"]}"

But, when I try to use it in the new server, it just sends me a Json like that:

Code: Select all
"<\!-- localhost -->{"horario":["Lunes (libre)","Martes (libre)","Mi\u00e9rcoles (libre)","Jueves (libre)","Viernes (libre)"]}"

And I get a "parsererror", because I don't know why the function, or where is inserted that comment (Localhost is that i'm trying it in XAMPP for debug it and error stills here).

It could be for Apache conf.?

Code of the function where I call the getJson is here:
Code: Select all
     <script type="text/javascript">
        $(document).ready(function() {
            $('#solicitud_hora').attr('disabled', true);
            function peticion(cual){
                $prueba=$.getJSON( "<?php echo url_for('profesores/get_horario', true );?>/id/<?php echo $sf_request->getParameter('id');?>/mes/" + cual,
                function( data ) {
                    var options = '';
                    $('#solicitud_hora').attr('disabled', false);
                    for (var i = 0; i < data.horario.length; i++) {
                        options += '<option value="' + data.horario[i] + '">' + data.horario[i] + '</option>';

And the getter function when i take data from database and send it in JSON format is:
Code: Select all
    public function executeGet_horario(sfWebRequest $request) {
            $idActividad = $request->getParameter('id');
            $mes = $request->getParameter('mes');
            $this->forward404If($idActividad == '' || !ctype_digit((string) $idActividad));
            $actividad = ActividadPeer::retrieveByPK($idActividad);
            $this->forward404If(!$actividad || $actividad->getVisible() != 1 || $actividad->getBorrado() != 0);
            $arrRtn = array();
            foreach ($actividad->getOptions($mes) as $valor)
                $arrRtn[] = $valor;
            return $this->renderText(json_encode(array('horario' => $arrRtn)));

Anybody has the same problem with this?

Sorry for my poor english. Thanks in advance :D
Junior Member
Posts: 1
Joined: Thu Mar 12, 2015 1:22 pm