jquery - Json with strange names -



jquery - Json with strange names -

first sorry english

i have problem json.

assume next array in php

$msg['keyone'] = "bla1"; $msg['key_two'] = "bla2"; $msg['key-three'] = "bla3";

i convert json

json_encode($idioma);

then load ajax / jquery successfully

$.ajax({ type: "post", url: "somepage.php", contenttype: "application/json; charset=utf-8", datatype: "json", success: function(data) { alert(data.keyone); // ok (bla1) alert(data.key_two); // ok (bla2) alert(data.key-three); // error (obviously)!!!! }, });

exist way/syntax access "key-three".

i can't rename keys, have maintain ugly names.

thanks!!

you can access data['key-three'].

jquery ajax json

Comments

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -