First sorry for my English
I have a problem with JSON.
Assume the following array in PHP
$msg['keyone'] = "bla1";
$msg['key_two'] = "bla2";
$msg['key-three'] = "bla3";
I convert it into JSON
json_encode($idioma);
Then load it with 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 any way/syntax to access “key-three”.
I can’t rename the keys, I have to keep those ugly names.
Thanks!!
You can access it like
data['key-three'].