English 中文(简体)
缩略语
原标题:Json with strange names

www.un.org/Depts/DGACM/index_spanish.htm 我的英语第一次问候

我与智者有问题。

在PHP中配置以下阵列:

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

我把它改为“JSON”。

json_encode($idioma);

然后用AJAX /jQuery成功装载。

$.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)!!!!            
    },
});

进出“三重”

www.un.org/Depts/DGACM/index_spanish.htm 我可以重新命名钥匙,我必须保留这些名字。

感谢!

最佳回答

您可以查阅<代码>数据[关键三个]

问题回答

2. 使用索引风格的辛塔克斯

alert(data[ keyone ]);
alert(data[ key_two ]);
alert(data[ key-three ]);




相关问题
ajax login using httpRequest?

I am trying to develop my login script to give feedback to the user if the login is valid or not. Basically if it isn t correct a div box will show saying its wrong, if its correct it will show its ...

Virtual Tour using sketch up, ajax, flash technologies

I want to know if there are existing technology that make your 3d models in sketch into virtual tours, using either Ajax or Flash for web presentation. If there s none, which will be a good approach ...

How can i update div continuously

I have asp.net application where i have a div which showing the value from other site. The value of that site is changing continuously. I want that my div will automatically update in some interval ...

热门标签