I'm having trouble making an Ajax call using AngularJS because the strings that have accents are returning null, as a response to the call, my PHP is returning a JSON json_encode($data)
, and upon receiving the answer I'm transforming JSON in an array angular.fromJson(data)
, just as it was on my server-side.
My PHP header is set to header("Content-Type: text/html; charset=ISO-8859-1",true)
, when I return var_dump
I can see all strings, accented or not. The problem is with JSON, I think the solution is a suitable header for my request .
This is my script:
$http.get("busca_tamanhos.php", {headers: {'Content-Type': 'application/json, text/plain'}}).success(function(data){
$scope.tamanhos = angular.fromJson(data);
$window.console.log(data);
});
PS: I can see non-accented strings, and my database is ISO-8859-1.