1
Hello, I am consuming data from a webservice where I Gero a json by PHP json_encode.
require_once('../lib/nusoap.php');
$client = new nusoap_client('http://dominio.com.br/webservice/ws?wsdl', true);
$result = $client->call('getUnidades');
header('Access-Control-Allow-Origin: *');
header( 'Content-Type: application/json' );
echo(json_encode($result));
In the development environment I have this result:
[{"valor":"brasilia","legenda":"Bras\u00edlia (DF)"},{"valor":"osasconew","legenda":"Osasco (SP)"}]
But in the production environment that Locaweb is like this:
[{valor:brasilia,legenda:Bras\u00edlia (DF)},{valor:osasconew,legenda:Osasco (SP)}]
It is without quotes and this is giving syntax error in javascript SyntaxError: JSON.parse: expected property name or '}
The javascript function is like this:
showUnits: function(){
$.ajax({
dataType: "json",
url:"webservices/get-unidades.php",
success: function(data){
jason = $.parseJSON(data);
$.each(jason, function(i, item){
$('#slcUnidade').append('<option value="'+ item.valor +'">'+ item.legenda +'</option>');
});
},
error: function(){
$('#slcUnidade').append('<option>Não há unidades diponíveis</option>');
}
});
}
I would like a help to solve this json problem without quotation marks on Locaweb.
Thank you.
You can explain better where you are finding this quote-free JSON?
– Sergio