我有打印json對象的問題。在螢火蟲我可以看到這是從Ajax調用返回。用jquery打印json對象
ABOUT
"Company"
CONTACT
"Contacts"
FAKTY
"Facts"
KARIERA
"Career"
等
這是我的Ajax調用
$.ajax({
url: 'defines/defines_en.php',
dataType: 'json',
complete: function (data) {
if (data.status == 200){
alert(data['ABOUT']);
alert(data.ABOUT);
}
else {
alert("Nepodarilo sa zmeniť jazyk");
}
}
});
它讓我在這兩個警報定義。
有人可以幫忙嗎?
UPDATE defines_en.php文件:
<?php
$data = array(
'PORTFOLIO'=>'Portfolio',
'ABOUT'=>'Company',
'CONTACT'=>'Contacts',
'ZALOHOVANIE'=>'Backup and Archivation',
'KONSOLIDACIA'=>'Consolidation and Virtualization',
'MANAZMENT'=>'Management and Monitoring',
'NETWORKSEC'=>'Network security',
'SPRAVAKONC'=>'Správa koncových zariadení',
'FAKTY'=>'Facts',
'MGMT'=>'Management',
'REF'=>'References',
'KARIERA'=>'Career',
);
echo json_encode($data);
?>
更新2警報(JSON.stringify(數據)):
{"readyState":4,"responseText":"{\"PORTFOLIO\":\"Portfolio\",\"ABOUT\":\"Company\",\"CONTACT\":\"Contacts\",\"ZALOHOVANIE\":\"Backup and Archivation\",\"KONSOLIDACIA\":\"Consolidation and Virtualization\",\"MANAZMENT\":\"Management and Monitoring\",\"NETWORKSEC\":\"Network security\",\"SPRAVAKONC\":\"Spr\\u00e1va koncov\\u00fdch zariaden\\u00ed\",\"FAKTY\":\"Facts\",\"MGMT\":\"Management\",\"REF\":\"References\",\"KARIERA\":\"Career\"}","responseJSON":{"PORTFOLIO":"Portfolio","ABOUT":"Company","CONTACT":"Contacts","ZALOHOVANIE":"Backup and Archivation","KONSOLIDACIA":"Consolidation and Virtualization","MANAZMENT":"Management and Monitoring","NETWORKSEC":"Network security","SPRAVAKONC":"Správa koncových zariadení","FAKTY":"Facts","MGMT":"Management","REF":"References","KARIERA":"Career"},"status":200,"statusText":"OK"}
這看起來不像JSON。 – kapa
請張貼數據的值,而不是僞代碼或任何它是 –
@Martin這不是一個有效的JSON。有關更多信息,請轉至[JSON官方網站](http://json.org/) –