Symfony ajax Response but with headers: HTTP/1.0 200 OK Cache-Control: no-cache Date
ajax, header, http, php, symfony
Solution
I found the solution to my big problem:
`->getContent()` at the end of $points = `self::pointsAction($id);`
Problem
i'm in troubles with Symfony and an ajax call. I'm in Local server on Windows 8 with XAMPP 1.8.2. Every works good, but when i take response i have this, below the right text: ``` HTTP/1.0 200 OK Cache-Control: no-cache Date: Tue, 19 Nov 2013 14:58:18 ``` Why? My codes: In HTML (Twig) at the bottom: ``` $.ajax({ url: "{{ path('score') }}", data: { id: scoreid, value: value }, dataType: 'json', type: 'POST', success: function (data) { if(data.responseCode==200 ){ $('#score').html(data.score); $('#score').css("color","green"); } else if(data.responseCode==400){ $('#score').html(data.score); $('#score').css("color","red"); } else{ alert("An unexpeded error occured."); $('#score').html(data); } }, error: function (jxhr, msg, err) { $('#score').html('<span style="color:red">Error!</span>'); } }); ``` Controller "score": ``` class scoreController extends Controller { public function onepointAction(Request $request) { ....some logical... $points = self::pointsAction($id); $return=array("responseCode"=>200, "score"=>"Score: ".$num.".", "goal"=>"".$points); } else { $return=array("responseCode"=>400, "score"=>"No good!"); } $return = json_encode($return); return new Response($return,200,array('Content-Type'=>'application/json')); } public function pointsAction($id) { ......some logical query... ended by: ->getQuery(); $pointsOk = $query->getResult(); $avgScore = $avgScore[0]["score_avg"]; $numScore = $avgPoints[0]["score_count"]; $points = ("Scores: ".$avgScore."Goals: ".$numScore); return new Response($points); } } ``` Where I make error?