false (and true) and numbers are valid JSON values. You *can* put them in quotes, but that changes their meaning: they become strings instead of boolean or numeric values.
It's true that you would want to use the properties of the msg object such as msg.descrizione, but it's also fine to call alert(msg). It should alert this text: [object Object] I wouldn't use msg as the variable name, since that sounds like an abbreviation for "message" - and this is an object, not a message string. But that wouldn't affect how the code works. That said, it's pretty hard to tell what might be wrong. Luca, I assume that the line break between "del" and "computer" is not present in the actual JSON text, but is simply an artifact introduced in the email post, is that correct? Can you post a link to a test page that demonstrates the problem? That would make it much easier (i.e. it would make it *possible*) to help you. -Mike On Wed, Nov 18, 2009 at 1:55 PM, Carlos Alberto <card...@gmail.com> wrote: > I think you must encapsulate "false" and numbers in quotes... > > and treat msg like an object (msg.descrizione, msg. disponibile... > etc.) > > On 18 nov, 17:43, sportfantasy <luca.santanie...@email.it> wrote: > > Hi, > > > > I'm italian developer. I have a problem. I develope my simple web > > application using jquery for ajax call. > > > > My Servlet return json string generated with json-lib... for example: > > {"descrizione":"Questa รจ la descrizione del > > computer","disponibile":false,"id":1,"nome":"Computer","prezzo": > > 123.456} > > > > My jsp page contains a simple nutton that call follow js function: > > > > $.ajax({ > > url: "json?method=prodotti", > > global: false, > > type: "POST", > > dataType: "json", > > success: function(msg){ > > alert(msg); > > > > } > > }); > > > > Application run correcty... > > > > Only problem is mozilla/firefox browser... In js console appears this > > message: > > > > Errore: non well-formed > > File sorgente: ... > > Riga: 1, Colonna: 1 > > Codice sorgente: > > {"descrizione":"Questa ? la descrizione del > > computer","disponibile":false,"id":1,"nome":"Computer","prezzo": > > 123.456} > > > > Why? How can I solve it? > > > > Sorry for my english. I hope solve my problem > > > > Thanks > > > > Luca >